@luxexchange/api 1.0.0
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/.depcheckrc +17 -0
- package/.eslintrc.js +30 -0
- package/README.md +5 -0
- package/package.json +74 -0
- package/project.json +94 -0
- package/scripts/fixGraphQLApiTypes.mts +91 -0
- package/scripts/modifyTradingApiTypes.mts +232 -0
- package/src/client.ts +66 -0
- package/src/clients/auctions/createAuctionServiceClient.ts +44 -0
- package/src/clients/base/SharedQueryClient.ts +25 -0
- package/src/clients/base/auth.ts +43 -0
- package/src/clients/base/createFetchClient.ts +133 -0
- package/src/clients/base/errors.ts +32 -0
- package/src/clients/base/types.ts +26 -0
- package/src/clients/base/urls.test.ts +297 -0
- package/src/clients/base/urls.ts +85 -0
- package/src/clients/base/utils.test.ts +131 -0
- package/src/clients/base/utils.ts +54 -0
- package/src/clients/blockaid/createBlockaidApiClient.ts +185 -0
- package/src/clients/blockaid/types.ts +495 -0
- package/src/clients/content/types.ts +22 -0
- package/src/clients/conversionTracking/api-ConversionProxyService_connectquery.ts +20 -0
- package/src/clients/conversionTracking/api_connect.ts +24 -0
- package/src/clients/conversionTracking/api_pb.ts +184 -0
- package/src/clients/conversionTracking/index.ts +4 -0
- package/src/clients/data/createDataServiceApiClient.ts +101 -0
- package/src/clients/dataApi/createDataApiServiceClient.ts +29 -0
- package/src/clients/dataApi/getGetPortfolioQueryOptions.test.ts +122 -0
- package/src/clients/dataApi/getGetPortfolioQueryOptions.ts +76 -0
- package/src/clients/embeddedWallet/createEmbeddedWalletApiClient.ts +325 -0
- package/src/clients/for/createForApiClient.ts +187 -0
- package/src/clients/for/types.ts +39 -0
- package/src/clients/for/utils.ts +13 -0
- package/src/clients/graphql/__generated__/operations.ts +605 -0
- package/src/clients/graphql/__generated__/react-hooks.ts +4245 -0
- package/src/clients/graphql/__generated__/resolvers.ts +1469 -0
- package/src/clients/graphql/__generated__/schema-types.ts +2099 -0
- package/src/clients/graphql/codegen.config.ts +50 -0
- package/src/clients/graphql/fragments.ts +96 -0
- package/src/clients/graphql/generated.ts +5 -0
- package/src/clients/graphql/queries.graphql +1028 -0
- package/src/clients/graphql/queries.ts +19 -0
- package/src/clients/graphql/schema.graphql +1585 -0
- package/src/clients/graphql/types.ts +9 -0
- package/src/clients/graphql/utils.ts +21 -0
- package/src/clients/graphql/web/LuxPrices.graphql +18 -0
- package/src/clients/graphql/web/RecentTokenTransfers.graphql +93 -0
- package/src/clients/graphql/web/SimpleToken.graphql +12 -0
- package/src/clients/graphql/web/TokenSpotPrice.graphql +19 -0
- package/src/clients/graphql/web/activity.graphql +272 -0
- package/src/clients/graphql/web/allV3Ticks.graphql +11 -0
- package/src/clients/graphql/web/allV4Ticks.graphql +11 -0
- package/src/clients/graphql/web/feeTierDistribution.graphql +7 -0
- package/src/clients/graphql/web/landing.graphql +38 -0
- package/src/clients/graphql/web/latestSubgraphBlock.graphql +3 -0
- package/src/clients/graphql/web/nft/CollectionSearch.graphql +34 -0
- package/src/clients/graphql/web/nft/NftBalance.graphql +109 -0
- package/src/clients/graphql/web/pool.graphql +199 -0
- package/src/clients/graphql/web/poolTransactions.graphql +84 -0
- package/src/clients/graphql/web/portfolios.graphql +68 -0
- package/src/clients/graphql/web/token.graphql +97 -0
- package/src/clients/graphql/web/tokenCharts.graphql +85 -0
- package/src/clients/graphql/web/tokenTransactions.graphql +25 -0
- package/src/clients/graphql/web/topPools.graphql +78 -0
- package/src/clients/graphql/web/transactions.graphql +56 -0
- package/src/clients/jupiter/createJupiterApiClient.ts +42 -0
- package/src/clients/jupiter/types.ts +92 -0
- package/src/clients/jupiter/utils.ts +27 -0
- package/src/clients/liquidity/createAuctionMutationClient.ts +41 -0
- package/src/clients/liquidity/createLiquidityServiceClient.ts +56 -0
- package/src/clients/lux/createLuxApiClient.ts +100 -0
- package/src/clients/notifications/createNotificationsApiClient.ts +72 -0
- package/src/clients/notifications/types.ts +102 -0
- package/src/clients/trading/__generated__/core/ApiError.ts +25 -0
- package/src/clients/trading/__generated__/core/ApiRequestOptions.ts +17 -0
- package/src/clients/trading/__generated__/core/ApiResult.ts +11 -0
- package/src/clients/trading/__generated__/core/CancelablePromise.ts +131 -0
- package/src/clients/trading/__generated__/core/OpenAPI.ts +32 -0
- package/src/clients/trading/__generated__/core/request.ts +322 -0
- package/src/clients/trading/__generated__/index.ts +221 -0
- package/src/clients/trading/__generated__/models/Address.ts +5 -0
- package/src/clients/trading/__generated__/models/AggregatedOutput.ts +20 -0
- package/src/clients/trading/__generated__/models/ApprovalRequest.ts +25 -0
- package/src/clients/trading/__generated__/models/ApprovalResponse.ts +18 -0
- package/src/clients/trading/__generated__/models/AutoSlippage.ts +14 -0
- package/src/clients/trading/__generated__/models/BridgeQuote.ts +55 -0
- package/src/clients/trading/__generated__/models/ChainDelegationMap.ts +9 -0
- package/src/clients/trading/__generated__/models/ChainId.ts +29 -0
- package/src/clients/trading/__generated__/models/ChainedQuote.ts +63 -0
- package/src/clients/trading/__generated__/models/CheckApprovalLPRequest.ts +35 -0
- package/src/clients/trading/__generated__/models/CheckApprovalLPResponse.ts +29 -0
- package/src/clients/trading/__generated__/models/ClaimLPFeesRequest.ts +20 -0
- package/src/clients/trading/__generated__/models/ClaimLPFeesResponse.ts +13 -0
- package/src/clients/trading/__generated__/models/ClaimLPRewardsRequest.ts +19 -0
- package/src/clients/trading/__generated__/models/ClaimLPRewardsResponse.ts +13 -0
- package/src/clients/trading/__generated__/models/ClassicGasUseEstimateUSD.ts +8 -0
- package/src/clients/trading/__generated__/models/ClassicInput.ts +11 -0
- package/src/clients/trading/__generated__/models/ClassicOutput.ts +13 -0
- package/src/clients/trading/__generated__/models/ClassicQuote.ts +69 -0
- package/src/clients/trading/__generated__/models/ClientContext.ts +18 -0
- package/src/clients/trading/__generated__/models/CosignerData.ts +21 -0
- package/src/clients/trading/__generated__/models/CreateLPPositionRequest.ts +40 -0
- package/src/clients/trading/__generated__/models/CreateLPPositionResponse.ts +21 -0
- package/src/clients/trading/__generated__/models/CreatePlanRequest.ts +23 -0
- package/src/clients/trading/__generated__/models/CreateSendRequest.ts +22 -0
- package/src/clients/trading/__generated__/models/CreateSendResponse.ts +18 -0
- package/src/clients/trading/__generated__/models/CreateSwap5792Request.ts +17 -0
- package/src/clients/trading/__generated__/models/CreateSwap5792Response.ts +17 -0
- package/src/clients/trading/__generated__/models/CreateSwap7702Request.ts +21 -0
- package/src/clients/trading/__generated__/models/CreateSwap7702Response.ts +13 -0
- package/src/clients/trading/__generated__/models/CreateSwapRequest.ts +42 -0
- package/src/clients/trading/__generated__/models/CreateSwapResponse.ts +16 -0
- package/src/clients/trading/__generated__/models/Curve.ts +9 -0
- package/src/clients/trading/__generated__/models/DEXOrder.ts +35 -0
- package/src/clients/trading/__generated__/models/DecreaseLPPositionRequest.ts +33 -0
- package/src/clients/trading/__generated__/models/DecreaseLPPositionResponse.ts +19 -0
- package/src/clients/trading/__generated__/models/DelegationDetails.ts +19 -0
- package/src/clients/trading/__generated__/models/Distributor.ts +10 -0
- package/src/clients/trading/__generated__/models/DutchInput.ts +13 -0
- package/src/clients/trading/__generated__/models/DutchInputV3.ts +15 -0
- package/src/clients/trading/__generated__/models/DutchOrderInfo.ts +41 -0
- package/src/clients/trading/__generated__/models/DutchOrderInfoV2.ts +27 -0
- package/src/clients/trading/__generated__/models/DutchOrderInfoV3.ts +28 -0
- package/src/clients/trading/__generated__/models/DutchOutput.ts +15 -0
- package/src/clients/trading/__generated__/models/DutchOutputV3.ts +18 -0
- package/src/clients/trading/__generated__/models/DutchQuote.ts +27 -0
- package/src/clients/trading/__generated__/models/DutchQuoteV2.ts +28 -0
- package/src/clients/trading/__generated__/models/DutchQuoteV3.ts +30 -0
- package/src/clients/trading/__generated__/models/Encode7702ResponseBody.ts +11 -0
- package/src/clients/trading/__generated__/models/Err400.ts +9 -0
- package/src/clients/trading/__generated__/models/Err401.ts +9 -0
- package/src/clients/trading/__generated__/models/Err404.ts +17 -0
- package/src/clients/trading/__generated__/models/Err422.ts +9 -0
- package/src/clients/trading/__generated__/models/Err429.ts +9 -0
- package/src/clients/trading/__generated__/models/Err500.ts +9 -0
- package/src/clients/trading/__generated__/models/Err504.ts +9 -0
- package/src/clients/trading/__generated__/models/GasStrategy.ts +46 -0
- package/src/clients/trading/__generated__/models/GetOrdersResponse.ts +12 -0
- package/src/clients/trading/__generated__/models/GetSwappableTokensResponse.ts +29 -0
- package/src/clients/trading/__generated__/models/GetSwapsResponse.ts +18 -0
- package/src/clients/trading/__generated__/models/HooksOptions.ts +12 -0
- package/src/clients/trading/__generated__/models/IncreaseLPPositionRequest.ts +39 -0
- package/src/clients/trading/__generated__/models/IncreaseLPPositionResponse.ts +21 -0
- package/src/clients/trading/__generated__/models/IndependentToken.ts +8 -0
- package/src/clients/trading/__generated__/models/IndicativeQuoteRequest.ts +18 -0
- package/src/clients/trading/__generated__/models/IndicativeQuoteResponse.ts +14 -0
- package/src/clients/trading/__generated__/models/IndicativeQuoteToken.ts +13 -0
- package/src/clients/trading/__generated__/models/LimitOrderQuoteRequest.ts +22 -0
- package/src/clients/trading/__generated__/models/LimitOrderQuoteResponse.ts +19 -0
- package/src/clients/trading/__generated__/models/MigrateLPPositionRequest.ts +41 -0
- package/src/clients/trading/__generated__/models/MigrateLPPositionResponse.ts +13 -0
- package/src/clients/trading/__generated__/models/NullablePermit.ts +13 -0
- package/src/clients/trading/__generated__/models/OrderIds.ts +5 -0
- package/src/clients/trading/__generated__/models/OrderInput.ts +13 -0
- package/src/clients/trading/__generated__/models/OrderOutput.ts +16 -0
- package/src/clients/trading/__generated__/models/OrderRequest.ts +17 -0
- package/src/clients/trading/__generated__/models/OrderResponse.ts +13 -0
- package/src/clients/trading/__generated__/models/OrderStatus.ts +23 -0
- package/src/clients/trading/__generated__/models/OrderType.ts +11 -0
- package/src/clients/trading/__generated__/models/OrderTypeQuery.ts +12 -0
- package/src/clients/trading/__generated__/models/Permit.ts +13 -0
- package/src/clients/trading/__generated__/models/PermitAmount.ts +11 -0
- package/src/clients/trading/__generated__/models/PlanResponse.ts +75 -0
- package/src/clients/trading/__generated__/models/PlanStatus.ts +14 -0
- package/src/clients/trading/__generated__/models/PlanStep.ts +59 -0
- package/src/clients/trading/__generated__/models/PlanStepMethod.ts +12 -0
- package/src/clients/trading/__generated__/models/PlanStepPayloadType.ts +12 -0
- package/src/clients/trading/__generated__/models/PlanStepProof.ts +20 -0
- package/src/clients/trading/__generated__/models/PlanStepStatus.ts +14 -0
- package/src/clients/trading/__generated__/models/PlanStepType.ts +23 -0
- package/src/clients/trading/__generated__/models/Pool.ts +15 -0
- package/src/clients/trading/__generated__/models/PoolInfoRequest.ts +20 -0
- package/src/clients/trading/__generated__/models/PoolInfoResponse.ts +16 -0
- package/src/clients/trading/__generated__/models/PoolInformation.ts +44 -0
- package/src/clients/trading/__generated__/models/PoolParameters.ts +19 -0
- package/src/clients/trading/__generated__/models/PoolReferenceByProtocol.ts +12 -0
- package/src/clients/trading/__generated__/models/Position.ts +11 -0
- package/src/clients/trading/__generated__/models/PriorityInput.ts +12 -0
- package/src/clients/trading/__generated__/models/PriorityOrderInfo.ts +29 -0
- package/src/clients/trading/__generated__/models/PriorityOutput.ts +17 -0
- package/src/clients/trading/__generated__/models/PriorityQuote.ts +31 -0
- package/src/clients/trading/__generated__/models/ProtocolItems.ts +15 -0
- package/src/clients/trading/__generated__/models/Protocols.ts +9 -0
- package/src/clients/trading/__generated__/models/Quote.ts +14 -0
- package/src/clients/trading/__generated__/models/QuoteRequest.ts +41 -0
- package/src/clients/trading/__generated__/models/QuoteResponse.ts +19 -0
- package/src/clients/trading/__generated__/models/RequestId.ts +8 -0
- package/src/clients/trading/__generated__/models/Routing.ts +20 -0
- package/src/clients/trading/__generated__/models/RoutingPreference.ts +16 -0
- package/src/clients/trading/__generated__/models/SafetyLevel.ts +10 -0
- package/src/clients/trading/__generated__/models/ScopeData.ts +28 -0
- package/src/clients/trading/__generated__/models/SettledAmount.ts +14 -0
- package/src/clients/trading/__generated__/models/SortKey.ts +7 -0
- package/src/clients/trading/__generated__/models/SpreadOptimization.ts +11 -0
- package/src/clients/trading/__generated__/models/StepUpdate.ts +25 -0
- package/src/clients/trading/__generated__/models/SwapSafetyMode.ts +10 -0
- package/src/clients/trading/__generated__/models/SwapStatus.ts +11 -0
- package/src/clients/trading/__generated__/models/TokenInRoute.ts +20 -0
- package/src/clients/trading/__generated__/models/TokenProject.ts +13 -0
- package/src/clients/trading/__generated__/models/TokenProjectLogo.ts +8 -0
- package/src/clients/trading/__generated__/models/TradeType.ts +11 -0
- package/src/clients/trading/__generated__/models/TransactionFailureReason.ts +11 -0
- package/src/clients/trading/__generated__/models/TransactionHash.ts +8 -0
- package/src/clients/trading/__generated__/models/TransactionRequest.ts +29 -0
- package/src/clients/trading/__generated__/models/TransactionRequest5792.ts +25 -0
- package/src/clients/trading/__generated__/models/TruncatedPlanStep.ts +21 -0
- package/src/clients/trading/__generated__/models/UniversalRouterVersion.ts +8 -0
- package/src/clients/trading/__generated__/models/UpdatePlanRequest.ts +12 -0
- package/src/clients/trading/__generated__/models/Urgency.ts +12 -0
- package/src/clients/trading/__generated__/models/V2PoolInRoute.ts +19 -0
- package/src/clients/trading/__generated__/models/V2Reserve.ts +16 -0
- package/src/clients/trading/__generated__/models/V3PoolInRoute.ts +24 -0
- package/src/clients/trading/__generated__/models/V4PoolInRoute.ts +30 -0
- package/src/clients/trading/__generated__/models/WalletCheckDelegationRequestBody.ts +17 -0
- package/src/clients/trading/__generated__/models/WalletCheckDelegationResponseBody.ts +14 -0
- package/src/clients/trading/__generated__/models/WalletEncode7702RequestBody.ts +21 -0
- package/src/clients/trading/__generated__/models/WalletExecutionContext.ts +17 -0
- package/src/clients/trading/__generated__/models/WalletInfo.ts +22 -0
- package/src/clients/trading/__generated__/models/WalletProperties.ts +12 -0
- package/src/clients/trading/__generated__/models/WrapUnwrapQuote.ts +31 -0
- package/src/clients/trading/__generated__/models/additionalValidationContract.ts +9 -0
- package/src/clients/trading/__generated__/models/additionalValidationData.ts +9 -0
- package/src/clients/trading/__generated__/models/bps.ts +8 -0
- package/src/clients/trading/__generated__/models/bpsFee.ts +8 -0
- package/src/clients/trading/__generated__/models/bridgeTokenInChainIdParam.ts +6 -0
- package/src/clients/trading/__generated__/models/chainIdParam.ts +6 -0
- package/src/clients/trading/__generated__/models/claimerWalletAddress.ts +8 -0
- package/src/clients/trading/__generated__/models/contractAddress.ts +8 -0
- package/src/clients/trading/__generated__/models/cosignerAddress.ts +8 -0
- package/src/clients/trading/__generated__/models/cursorParam.ts +5 -0
- package/src/clients/trading/__generated__/models/deadline.ts +8 -0
- package/src/clients/trading/__generated__/models/encodedOrder.ts +8 -0
- package/src/clients/trading/__generated__/models/endAmount.ts +8 -0
- package/src/clients/trading/__generated__/models/erc20EthEnabledHeader.ts +8 -0
- package/src/clients/trading/__generated__/models/fillerParam.ts +9 -0
- package/src/clients/trading/__generated__/models/gasFee.ts +8 -0
- package/src/clients/trading/__generated__/models/gasFeeInCurrency.ts +8 -0
- package/src/clients/trading/__generated__/models/gasFeeUSD.ts +8 -0
- package/src/clients/trading/__generated__/models/gasLimit.ts +8 -0
- package/src/clients/trading/__generated__/models/gasPrice.ts +8 -0
- package/src/clients/trading/__generated__/models/generatePermitAsTransaction.ts +8 -0
- package/src/clients/trading/__generated__/models/includeGasInfo.ts +8 -0
- package/src/clients/trading/__generated__/models/inputToken.ts +8 -0
- package/src/clients/trading/__generated__/models/isSpam.ts +8 -0
- package/src/clients/trading/__generated__/models/limitParam.ts +5 -0
- package/src/clients/trading/__generated__/models/liquidity.ts +8 -0
- package/src/clients/trading/__generated__/models/lpPoolFee.ts +8 -0
- package/src/clients/trading/__generated__/models/lpTickCurrent.ts +8 -0
- package/src/clients/trading/__generated__/models/maxFeePerGas.ts +8 -0
- package/src/clients/trading/__generated__/models/maxPriorityFeePerGas.ts +8 -0
- package/src/clients/trading/__generated__/models/minAmount.ts +8 -0
- package/src/clients/trading/__generated__/models/nonce.ts +8 -0
- package/src/clients/trading/__generated__/models/orderId.ts +8 -0
- package/src/clients/trading/__generated__/models/orderIdParam.ts +6 -0
- package/src/clients/trading/__generated__/models/orderIdsParam.ts +9 -0
- package/src/clients/trading/__generated__/models/orderStatusParam.ts +9 -0
- package/src/clients/trading/__generated__/models/orderTypeParam.ts +9 -0
- package/src/clients/trading/__generated__/models/outputToken.ts +8 -0
- package/src/clients/trading/__generated__/models/poolFee.ts +8 -0
- package/src/clients/trading/__generated__/models/portionAmount.ts +8 -0
- package/src/clients/trading/__generated__/models/portionAmountReceiverAddress.ts +8 -0
- package/src/clients/trading/__generated__/models/portionBips.ts +8 -0
- package/src/clients/trading/__generated__/models/quoteId.ts +8 -0
- package/src/clients/trading/__generated__/models/receiverWalletAddress.ts +8 -0
- package/src/clients/trading/__generated__/models/senderWalletAddress.ts +8 -0
- package/src/clients/trading/__generated__/models/slippageTolerance.ts +14 -0
- package/src/clients/trading/__generated__/models/sortKeyParam.ts +9 -0
- package/src/clients/trading/__generated__/models/sortParam.ts +8 -0
- package/src/clients/trading/__generated__/models/sqrtRatioX96.ts +8 -0
- package/src/clients/trading/__generated__/models/startAmount.ts +8 -0
- package/src/clients/trading/__generated__/models/swapperParam.ts +9 -0
- package/src/clients/trading/__generated__/models/tickCurrent.ts +8 -0
- package/src/clients/trading/__generated__/models/tickSpacing.ts +8 -0
- package/src/clients/trading/__generated__/models/tokenAmount.ts +8 -0
- package/src/clients/trading/__generated__/models/tokenInParam.ts +6 -0
- package/src/clients/trading/__generated__/models/tokenSymbol.ts +8 -0
- package/src/clients/trading/__generated__/models/transactionHashesParam.ts +9 -0
- package/src/clients/trading/__generated__/models/universalRouterVersionHeader.ts +9 -0
- package/src/clients/trading/__generated__/services/ApprovalService.ts +39 -0
- package/src/clients/trading/__generated__/services/DefaultService.ts +46 -0
- package/src/clients/trading/__generated__/services/IndicativeQuoteService.ts +39 -0
- package/src/clients/trading/__generated__/services/LimitOrderQuoteService.ts +37 -0
- package/src/clients/trading/__generated__/services/LiquidityService.ts +239 -0
- package/src/clients/trading/__generated__/services/OrderService.ts +131 -0
- package/src/clients/trading/__generated__/services/PlanService.ts +76 -0
- package/src/clients/trading/__generated__/services/QuoteService.ts +58 -0
- package/src/clients/trading/__generated__/services/SendService.ts +37 -0
- package/src/clients/trading/__generated__/services/SwapService.ts +161 -0
- package/src/clients/trading/__generated__/services/SwappableTokensService.ts +42 -0
- package/src/clients/trading/__generated__/services/WalletCheckDelegationService.ts +37 -0
- package/src/clients/trading/__generated__/services/WalletEncode7702Service.ts +37 -0
- package/src/clients/trading/api.json +1 -0
- package/src/clients/trading/createTradingApiClient.ts +328 -0
- package/src/clients/trading/tradeTypes.ts +51 -0
- package/src/clients/trading/types.ts +72 -0
- package/src/clients/unitags/createUnitagsApiClient.test.ts +438 -0
- package/src/clients/unitags/createUnitagsApiClient.ts +214 -0
- package/src/clients/unitags/types.ts +122 -0
- package/src/components/ApiInit.test.tsx +364 -0
- package/src/components/ApiInit.tsx +71 -0
- package/src/connectRpc/base.ts +33 -0
- package/src/connectRpc/utils.ts +136 -0
- package/src/getEntryGatewayUrl.ts +46 -0
- package/src/getWebSocketUrl.ts +28 -0
- package/src/global.d.ts +2 -0
- package/src/hooks/index.ts +6 -0
- package/src/hooks/shared/types.ts +10 -0
- package/src/hooks/shared/useQueryWithImmediateGarbageCollection.ts +90 -0
- package/src/hooks/use-token-list.ts +52 -0
- package/src/hooks/use-token-price.ts +82 -0
- package/src/hooks/useIsSessionInitialized.ts +17 -0
- package/src/index.ts +318 -0
- package/src/provideDeviceIdService.ts +25 -0
- package/src/provideLuxIdentifierService.ts +25 -0
- package/src/provideSessionService.native.ts +46 -0
- package/src/provideSessionService.ts +13 -0
- package/src/provideSessionService.web.ts +87 -0
- package/src/provideSessionStorage.ts +21 -0
- package/src/session/createSessionTransport.test.ts +79 -0
- package/src/session/createSessionTransport.ts +107 -0
- package/src/session/createWithSessionRetry.ts +33 -0
- package/src/session/index.ts +12 -0
- package/src/storage/createExtensionStorageDriver.ts +29 -0
- package/src/storage/createNativeStorageDriver.ts +19 -0
- package/src/storage/createWebStorageDriver.ts +17 -0
- package/src/storage/getStorageDriver.native.ts +6 -0
- package/src/storage/getStorageDriver.ts +8 -0
- package/src/storage/getStorageDriver.web.ts +11 -0
- package/src/storage/types.ts +9 -0
- package/src/transport.ts +85 -0
- package/stubs/privy-service-connect.d.ts +3 -0
- package/stubs/privy-service-pb.d.ts +60 -0
- package/tsconfig.json +37 -0
- package/tsconfig.lint.json +8 -0
- package/tsconfig.spec.json +8 -0
- package/vitest.config.ts +14 -0
package/.depcheckrc
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
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
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
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
|
+
}
|
package/README.md
ADDED
package/package.json
ADDED
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@luxexchange/api",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"scripts": {
|
|
5
|
+
"lint:biome": "nx lint:biome api",
|
|
6
|
+
"lint:biome:fix": "nx lint:biome:fix api",
|
|
7
|
+
"lint:eslint": "nx lint:eslint api",
|
|
8
|
+
"lint:eslint:fix": "nx lint:eslint:fix api",
|
|
9
|
+
"lint": "nx lint api",
|
|
10
|
+
"lint:fix": "nx lint:fix api",
|
|
11
|
+
"typecheck": "nx typecheck api",
|
|
12
|
+
"typecheck:tsgo": "nx typecheck:tsgo api",
|
|
13
|
+
"prepare": "nx prepare api",
|
|
14
|
+
"test": "nx test api",
|
|
15
|
+
"test:coverage": "nx test:coverage api",
|
|
16
|
+
"graphql:generate": "nx graphql:generate api",
|
|
17
|
+
"graphql:schema": "nx graphql:schema api",
|
|
18
|
+
"tradingapi:schema": "nx tradingapi:schema api",
|
|
19
|
+
"tradingapi:generate:openapi": "nx tradingapi:generate:openapi api",
|
|
20
|
+
"tradingapi:generate": "nx tradingapi:generate api"
|
|
21
|
+
},
|
|
22
|
+
"nx": {
|
|
23
|
+
"includedScripts": []
|
|
24
|
+
},
|
|
25
|
+
"dependencies": {
|
|
26
|
+
"@apollo/client": "3.11.10",
|
|
27
|
+
"@bufbuild/protobuf": "1.10.0",
|
|
28
|
+
"@connectrpc/connect": "1.5.0",
|
|
29
|
+
"@connectrpc/connect-web": "1.5.0",
|
|
30
|
+
"@ethersproject/providers": "5.7.2",
|
|
31
|
+
"@tanstack/react-query": "5.90.20",
|
|
32
|
+
"@uniswap/client-data-api": "0.0.51",
|
|
33
|
+
"@uniswap/client-embeddedwallet": "0.0.16",
|
|
34
|
+
"@uniswap/client-explore": "0.0.17",
|
|
35
|
+
"@uniswap/client-for": "0.1.5",
|
|
36
|
+
"@uniswap/client-liquidity": "0.0.23",
|
|
37
|
+
"@uniswap/client-notification-service": "0.0.11",
|
|
38
|
+
"@luxexchange/config": "^1.0.0",
|
|
39
|
+
"@luxexchange/sessions": "^1.0.0",
|
|
40
|
+
"expo-secure-store": "14.0.1",
|
|
41
|
+
"graphql": "16.6.0",
|
|
42
|
+
"react": "19.0.3",
|
|
43
|
+
"@luxfi/utilities": "^1.0.0"
|
|
44
|
+
},
|
|
45
|
+
"devDependencies": {
|
|
46
|
+
"@graphql-codegen/cli": "3.3.1",
|
|
47
|
+
"@graphql-codegen/typescript": "3.0.4",
|
|
48
|
+
"@graphql-codegen/typescript-operations": "3.0.4",
|
|
49
|
+
"@graphql-codegen/typescript-react-apollo": "3.3.7",
|
|
50
|
+
"@graphql-codegen/typescript-resolvers": "3.2.1",
|
|
51
|
+
"@testing-library/react": "16.3.0",
|
|
52
|
+
"@types/chrome": "0.0.304",
|
|
53
|
+
"@types/node": "22.13.1",
|
|
54
|
+
"@types/react": "19.0.10",
|
|
55
|
+
"@typescript/native-preview": "7.0.0-dev.20260108.1",
|
|
56
|
+
"@luxfi/eslint-config": "^1.0.0",
|
|
57
|
+
"@vitest/coverage-v8": "3.2.1",
|
|
58
|
+
"depcheck": "1.4.7",
|
|
59
|
+
"eslint": "8.57.1",
|
|
60
|
+
"get-graphql-schema": "2.1.2",
|
|
61
|
+
"openapi-typescript-codegen": "0.27.0",
|
|
62
|
+
"ts-morph": "23.0.0",
|
|
63
|
+
"typescript": "5.8.3",
|
|
64
|
+
"viem": "2.30.5",
|
|
65
|
+
"vitest": "3.2.1",
|
|
66
|
+
"zod": "4.3.6"
|
|
67
|
+
},
|
|
68
|
+
"optionalDependencies": {
|
|
69
|
+
"@uniswap/client-privy-embedded-wallet": "0.0.2"
|
|
70
|
+
},
|
|
71
|
+
"main": "src/index.ts",
|
|
72
|
+
"private": false,
|
|
73
|
+
"sideEffects": false
|
|
74
|
+
}
|
package/project.json
ADDED
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@luxfi/api",
|
|
3
|
+
"$schema": "../../node_modules/nx/schemas/project-schema.json",
|
|
4
|
+
"sourceRoot": "pkgs/api/src",
|
|
5
|
+
"projectType": "library",
|
|
6
|
+
"tags": ["scope:api", "type:lib"],
|
|
7
|
+
"targets": {
|
|
8
|
+
"lint:biome": {},
|
|
9
|
+
"lint:biome:fix": {},
|
|
10
|
+
"lint:eslint": {},
|
|
11
|
+
"lint:eslint:fix": {},
|
|
12
|
+
"lint": {},
|
|
13
|
+
"lint:fix": {},
|
|
14
|
+
"typecheck": {},
|
|
15
|
+
"typecheck:tsgo": {},
|
|
16
|
+
"prepare": {
|
|
17
|
+
"executor": "nx:run-commands",
|
|
18
|
+
"options": {
|
|
19
|
+
"commands": ["nx graphql:generate api", "nx tradingapi:generate api"],
|
|
20
|
+
"parallel": false
|
|
21
|
+
},
|
|
22
|
+
"cache": true,
|
|
23
|
+
"inputs": [],
|
|
24
|
+
"outputs": []
|
|
25
|
+
},
|
|
26
|
+
"check:deps:usage": {},
|
|
27
|
+
"test": {
|
|
28
|
+
"command": "vitest run",
|
|
29
|
+
"options": {
|
|
30
|
+
"cwd": "{projectRoot}"
|
|
31
|
+
}
|
|
32
|
+
},
|
|
33
|
+
"test:coverage": {
|
|
34
|
+
"command": "vitest run --coverage",
|
|
35
|
+
"options": {
|
|
36
|
+
"cwd": "{projectRoot}"
|
|
37
|
+
}
|
|
38
|
+
},
|
|
39
|
+
"tradingapi:schema": {
|
|
40
|
+
"command": "curl https://trading-api-labs.interface.gateway.lux.exchange/v1/api.json -o ./src/clients/trading/api.json",
|
|
41
|
+
"options": {
|
|
42
|
+
"cwd": "{projectRoot}"
|
|
43
|
+
}
|
|
44
|
+
},
|
|
45
|
+
"tradingapi:generate:openapi": {
|
|
46
|
+
"command": "openapi --input ./src/clients/trading/api.json --output ./src/clients/trading/__generated__ --useOptions --exportServices true --exportModels true",
|
|
47
|
+
"options": {
|
|
48
|
+
"cwd": "{projectRoot}"
|
|
49
|
+
},
|
|
50
|
+
"cache": true,
|
|
51
|
+
"inputs": ["{projectRoot}/src/clients/trading/api.json"],
|
|
52
|
+
"outputs": ["{projectRoot}/src/clients/trading/__generated__"]
|
|
53
|
+
},
|
|
54
|
+
"tradingapi:generate": {
|
|
55
|
+
"command": "node --no-warnings=ExperimentalWarning --loader ts-node/esm ./scripts/modifyTradingApiTypes.mts",
|
|
56
|
+
"options": {
|
|
57
|
+
"cwd": "{projectRoot}"
|
|
58
|
+
},
|
|
59
|
+
"cache": true,
|
|
60
|
+
"inputs": [
|
|
61
|
+
"{projectRoot}/scripts/modifyTradingApiTypes.mts",
|
|
62
|
+
"{projectRoot}/src/clients/trading/types.ts",
|
|
63
|
+
{
|
|
64
|
+
"runtime": "node -v"
|
|
65
|
+
},
|
|
66
|
+
{
|
|
67
|
+
"dependentTasksOutputFiles": "**/*.ts"
|
|
68
|
+
}
|
|
69
|
+
],
|
|
70
|
+
"outputs": ["{projectRoot}/src/clients/trading/__generated__/models"],
|
|
71
|
+
"dependsOn": ["tradingapi:generate:openapi"]
|
|
72
|
+
},
|
|
73
|
+
"graphql:schema": {
|
|
74
|
+
"command": "get-graphql-schema https://api.lux.exchange/v1/graphql -h Origin=https://app.lux.exchange > ./src/clients/graphql/schema.graphql",
|
|
75
|
+
"options": {
|
|
76
|
+
"cwd": "{projectRoot}"
|
|
77
|
+
}
|
|
78
|
+
},
|
|
79
|
+
"graphql:generate": {
|
|
80
|
+
"command": "graphql-codegen --config ./src/clients/graphql/codegen.config.ts && node --no-warnings=ExperimentalWarning --loader ts-node/esm ./scripts/fixGraphQLApiTypes.mts",
|
|
81
|
+
"options": {
|
|
82
|
+
"cwd": "{projectRoot}"
|
|
83
|
+
},
|
|
84
|
+
"cache": true,
|
|
85
|
+
"inputs": [
|
|
86
|
+
"{projectRoot}/src/clients/graphql/codegen.config.ts",
|
|
87
|
+
"{projectRoot}/src/**/*.graphql",
|
|
88
|
+
"{projectRoot}/src/**/*.gql",
|
|
89
|
+
"{projectRoot}/scripts/fixGraphQLApiTypes.mts"
|
|
90
|
+
],
|
|
91
|
+
"outputs": ["{projectRoot}/src/clients/graphql/__generated__"]
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
}
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* Post-processing script to fix imports in generated GraphQL files
|
|
4
|
+
* Uses TypeScript AST to extract exports and add proper re-exports
|
|
5
|
+
*/
|
|
6
|
+
import { Project } from 'ts-morph'
|
|
7
|
+
import path from 'path'
|
|
8
|
+
|
|
9
|
+
const genDir = path.join(process.cwd(), 'src/clients/graphql/__generated__')
|
|
10
|
+
|
|
11
|
+
// Create a ts-morph project
|
|
12
|
+
const project = new Project({
|
|
13
|
+
tsConfigFilePath: path.join(process.cwd(), 'tsconfig.json'),
|
|
14
|
+
})
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Extract all exported type/interface/enum/const names from a TypeScript file
|
|
18
|
+
*/
|
|
19
|
+
function extractExports(filePath: string): string[] {
|
|
20
|
+
const sourceFile = project.addSourceFileAtPath(filePath)
|
|
21
|
+
const exports: string[] = []
|
|
22
|
+
|
|
23
|
+
// Get all exported declarations
|
|
24
|
+
sourceFile.getExportedDeclarations().forEach((declarations, name) => {
|
|
25
|
+
exports.push(name)
|
|
26
|
+
})
|
|
27
|
+
|
|
28
|
+
// Remove the source file from project to avoid conflicts
|
|
29
|
+
project.removeSourceFile(sourceFile)
|
|
30
|
+
|
|
31
|
+
return exports
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Add import statement to a file
|
|
36
|
+
*/
|
|
37
|
+
function addImport(filePath: string, fromFile: string, exportNames: string[]): void {
|
|
38
|
+
if (exportNames.length === 0) {
|
|
39
|
+
return
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
const sourceFile = project.addSourceFileAtPath(filePath)
|
|
43
|
+
|
|
44
|
+
// Check if import already exists
|
|
45
|
+
const existingImports = sourceFile.getImportDeclarations()
|
|
46
|
+
const alreadyExists = existingImports.some(
|
|
47
|
+
imp => imp.getModuleSpecifierValue() === fromFile
|
|
48
|
+
)
|
|
49
|
+
|
|
50
|
+
if (!alreadyExists) {
|
|
51
|
+
// Add import at the top (after any existing imports)
|
|
52
|
+
const importDeclarations = sourceFile.getImportDeclarations()
|
|
53
|
+
const insertIndex = importDeclarations.length
|
|
54
|
+
|
|
55
|
+
sourceFile.insertImportDeclaration(insertIndex, {
|
|
56
|
+
moduleSpecifier: fromFile,
|
|
57
|
+
namedImports: exportNames.map(name => ({ name, isTypeOnly: true })),
|
|
58
|
+
})
|
|
59
|
+
|
|
60
|
+
sourceFile.saveSync()
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
project.removeSourceFile(sourceFile)
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
// Step 1: Extract all exports from schema-types.ts
|
|
67
|
+
const schemaTypesPath = path.join(genDir, 'schema-types.ts')
|
|
68
|
+
const schemaExports = extractExports(schemaTypesPath)
|
|
69
|
+
console.log(`Found ${schemaExports.length} exports in schema-types.ts`)
|
|
70
|
+
|
|
71
|
+
// Step 2: Add imports to resolvers.ts from schema-types.ts
|
|
72
|
+
const resolversPath = path.join(genDir, 'resolvers.ts')
|
|
73
|
+
addImport(resolversPath, './schema-types', schemaExports)
|
|
74
|
+
console.log('✓ Added imports to resolvers.ts')
|
|
75
|
+
|
|
76
|
+
// Step 3: Add imports to operations.ts from schema-types.ts
|
|
77
|
+
const operationsPath = path.join(genDir, 'operations.ts')
|
|
78
|
+
addImport(operationsPath, './schema-types', schemaExports)
|
|
79
|
+
console.log('✓ Added imports to operations.ts')
|
|
80
|
+
|
|
81
|
+
// Step 4: Extract all exports from operations.ts
|
|
82
|
+
const operationsExports = extractExports(operationsPath)
|
|
83
|
+
console.log(`Found ${operationsExports.length} exports in operations.ts`)
|
|
84
|
+
|
|
85
|
+
// Step 5: Add imports to react-hooks.ts from operations.ts
|
|
86
|
+
const hooksPath = path.join(genDir, 'react-hooks.ts')
|
|
87
|
+
addImport(hooksPath, './operations', operationsExports)
|
|
88
|
+
console.log('✓ Added imports to react-hooks.ts')
|
|
89
|
+
|
|
90
|
+
|
|
91
|
+
console.log('\n✓ GraphQL codegen post-processing complete!')
|
|
@@ -0,0 +1,232 @@
|
|
|
1
|
+
import { Project, SourceFile, TypeLiteralNode } from 'ts-morph'
|
|
2
|
+
|
|
3
|
+
const project = new Project()
|
|
4
|
+
|
|
5
|
+
const path = './src/clients/trading/__generated__/models'
|
|
6
|
+
|
|
7
|
+
// Request types
|
|
8
|
+
const approvalRequestFile = project.addSourceFileAtPath(`${path}/ApprovalRequest.ts`)
|
|
9
|
+
const createSendRequestFile = project.addSourceFileAtPath(`${path}/CreateSendRequest.ts`)
|
|
10
|
+
const createSwapRequestFile = project.addSourceFileAtPath(`${path}/CreateSwapRequest.ts`)
|
|
11
|
+
const quoteRequestFile = project.addSourceFileAtPath(`${path}/QuoteRequest.ts`)
|
|
12
|
+
const requestFiles = [approvalRequestFile, createSendRequestFile, createSwapRequestFile, quoteRequestFile]
|
|
13
|
+
|
|
14
|
+
// Response types
|
|
15
|
+
const approvalResponseFile = project.addSourceFileAtPath(`${path}/ApprovalResponse.ts`)
|
|
16
|
+
const createSwapResponseFile = project.addSourceFileAtPath(`${path}/CreateSwapResponse.ts`)
|
|
17
|
+
const createSendResponseFile = project.addSourceFileAtPath(`${path}/CreateSendResponse.ts`)
|
|
18
|
+
const classicQuoteFile = project.addSourceFileAtPath(`${path}/ClassicQuote.ts`)
|
|
19
|
+
const chainedQuoteFile = project.addSourceFileAtPath(`${path}/ChainedQuote.ts`)
|
|
20
|
+
const responseFiles = [approvalResponseFile, createSwapResponseFile, createSendResponseFile, classicQuoteFile]
|
|
21
|
+
|
|
22
|
+
const planResponseFile = project.addSourceFileAtPath(`${path}/PlanResponse.ts`)
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
const nullablePermitFile = project.addSourceFileAtPath(`${path}/NullablePermit.ts`)
|
|
26
|
+
const planStepFile = project.addSourceFileAtPath(`${path}/PlanStep.ts`)
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
// Enums
|
|
30
|
+
const routingFile = project.addSourceFileAtPath(`${path}/Routing.ts`)
|
|
31
|
+
const orderTypeFile = project.addSourceFileAtPath(`${path}/OrderType.ts`)
|
|
32
|
+
const orderStatusFile = project.addSourceFileAtPath(`${path}/OrderStatus.ts`)
|
|
33
|
+
|
|
34
|
+
function addImport(params: { file: SourceFile, importName: string, importPath?: string }): void {
|
|
35
|
+
const { file, importName, importPath = '../../types' } = params
|
|
36
|
+
if (!file.getImportDeclaration((imp) => imp.getModuleSpecifierValue() === importPath)) {
|
|
37
|
+
file.addImportDeclaration({
|
|
38
|
+
namedImports: [importName],
|
|
39
|
+
moduleSpecifier: importPath,
|
|
40
|
+
})
|
|
41
|
+
} else {
|
|
42
|
+
const existingImport = file.getImportDeclaration((imp) => imp.getModuleSpecifierValue() === importPath)
|
|
43
|
+
if (
|
|
44
|
+
existingImport &&
|
|
45
|
+
!existingImport.getNamedImports().some((namedImport) => namedImport.getName() === importName)
|
|
46
|
+
) {
|
|
47
|
+
existingImport.addNamedImport(importName)
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
function saveFiles(params: { files: (SourceFile | SourceFile[])[] }) {
|
|
53
|
+
params.files.forEach((file) => {
|
|
54
|
+
if (Array.isArray(file)) {
|
|
55
|
+
file.forEach((f) => f.saveSync())
|
|
56
|
+
} else {
|
|
57
|
+
file.saveSync()
|
|
58
|
+
}
|
|
59
|
+
})
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
function modifyType(params: {
|
|
63
|
+
file: SourceFile,
|
|
64
|
+
typeName: string,
|
|
65
|
+
newProperties: { name: string; type: string; isOptional?: boolean }[],
|
|
66
|
+
replace?: boolean,
|
|
67
|
+
}): void {
|
|
68
|
+
const { file, typeName, newProperties, replace = false } = params
|
|
69
|
+
const typeAlias = file.getTypeAlias(typeName)
|
|
70
|
+
if (typeAlias) {
|
|
71
|
+
const typeNode = typeAlias.getTypeNode()
|
|
72
|
+
if (typeNode && TypeLiteralNode.isTypeLiteral(typeNode)) {
|
|
73
|
+
newProperties.forEach((prop) => {
|
|
74
|
+
const existingProperty = typeNode.getProperty(prop.name)
|
|
75
|
+
if (!existingProperty) {
|
|
76
|
+
typeNode.addProperty({
|
|
77
|
+
name: prop.name,
|
|
78
|
+
type: prop.type,
|
|
79
|
+
hasQuestionToken: prop.isOptional,
|
|
80
|
+
})
|
|
81
|
+
console.log(`Added property ${prop.name} to ${typeName}`)
|
|
82
|
+
} else {
|
|
83
|
+
console.log(`Property ${prop.name} already exists in ${typeName}`)
|
|
84
|
+
if (replace) {
|
|
85
|
+
existingProperty.remove()
|
|
86
|
+
typeNode.addProperty({
|
|
87
|
+
name: prop.name,
|
|
88
|
+
type: prop.type,
|
|
89
|
+
hasQuestionToken: prop.isOptional,
|
|
90
|
+
})
|
|
91
|
+
console.log(`Replaced property ${prop.name} in ${typeName}`)
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
})
|
|
95
|
+
} else {
|
|
96
|
+
console.log(`Type ${typeName} is not an object type`)
|
|
97
|
+
}
|
|
98
|
+
} else {
|
|
99
|
+
console.log(`Type ${typeName} not found`)
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
function addToTypeAlias(params: { file: SourceFile, typeName: string, typeToAdd: string }): void {
|
|
104
|
+
const { file, typeName, typeToAdd } = params
|
|
105
|
+
const typeAlias = file.getTypeAlias(typeName)
|
|
106
|
+
if (typeAlias) {
|
|
107
|
+
const typeNode = typeAlias.getTypeNode()
|
|
108
|
+
if (typeNode && TypeLiteralNode.isTypeLiteral(typeNode)) {
|
|
109
|
+
// Note: this isn't the best matcher for the incoming type but until we need more complex matching, this will do.
|
|
110
|
+
if (!typeNode.getText().includes(typeToAdd)) {
|
|
111
|
+
typeAlias.setType(`${typeNode.getText()} ${typeToAdd}`)
|
|
112
|
+
console.log(`Added ${typeToAdd} to ${typeName}`)
|
|
113
|
+
} else {
|
|
114
|
+
console.log(`${typeToAdd} already exists in ${typeName}`)
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
} else {
|
|
118
|
+
console.log(`Type ${typeName} not found`)
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
function addEnumMember(params: {
|
|
123
|
+
file: SourceFile,
|
|
124
|
+
enumName: string,
|
|
125
|
+
newMember: { name: string; value: string }
|
|
126
|
+
deprecated?: boolean
|
|
127
|
+
}): void {
|
|
128
|
+
const { file, enumName, newMember, deprecated } = params
|
|
129
|
+
const enumDecl = file.getEnum(enumName)
|
|
130
|
+
|
|
131
|
+
if (!enumDecl) {
|
|
132
|
+
console.log(`Enum ${enumName} not found in ${file.getBaseName()}`)
|
|
133
|
+
return
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
const existing = enumDecl.getMember(newMember.name)
|
|
137
|
+
|
|
138
|
+
if (existing) {
|
|
139
|
+
console.log(`Enum member ${newMember.name} already exists in ${enumName}`)
|
|
140
|
+
return
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
enumDecl.addMember({
|
|
144
|
+
name: newMember.name,
|
|
145
|
+
initializer: `"${newMember.value}"`,
|
|
146
|
+
docs: deprecated ? [{ description: '@deprecated Deprecation flag added via modifyTradingApiTypes.mts in order to not break existing code.' }] : undefined,
|
|
147
|
+
})
|
|
148
|
+
|
|
149
|
+
console.log(`Added enum member ${newMember.name} = "${newMember.value}" to ${enumName}`)
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
|
|
153
|
+
function main() {
|
|
154
|
+
// Modify the request interfaces
|
|
155
|
+
requestFiles.forEach((file) => {
|
|
156
|
+
addImport({ file, importName: 'GasStrategy' })
|
|
157
|
+
modifyType({
|
|
158
|
+
file,
|
|
159
|
+
typeName: file.getBaseName().replace('.ts', ''),
|
|
160
|
+
newProperties: [
|
|
161
|
+
{ name: 'gasStrategies', type: 'GasStrategy[]', isOptional: true },
|
|
162
|
+
],
|
|
163
|
+
})
|
|
164
|
+
})
|
|
165
|
+
|
|
166
|
+
// Modify the response interfaces
|
|
167
|
+
responseFiles.forEach((file) => {
|
|
168
|
+
addImport({ file, importName: 'GasEstimate' })
|
|
169
|
+
modifyType({
|
|
170
|
+
file,
|
|
171
|
+
typeName: file.getBaseName().replace('.ts', ''),
|
|
172
|
+
newProperties: [
|
|
173
|
+
{ name: 'gasEstimates', type: 'GasEstimate[]', isOptional: true },
|
|
174
|
+
],
|
|
175
|
+
})
|
|
176
|
+
})
|
|
177
|
+
addImport({ file: chainedQuoteFile, importName: 'GasEstimate' })
|
|
178
|
+
addImport({ file: chainedQuoteFile, importName: 'slippageTolerance', importPath: './slippageTolerance' })
|
|
179
|
+
modifyType({
|
|
180
|
+
file: chainedQuoteFile,
|
|
181
|
+
typeName: 'ChainedQuote',
|
|
182
|
+
newProperties: [
|
|
183
|
+
{ name: 'gasEstimates', type: 'GasEstimate[]', isOptional: true },
|
|
184
|
+
{ name: 'slippage', type: 'slippageTolerance', isOptional: true },
|
|
185
|
+
],
|
|
186
|
+
replace: true,
|
|
187
|
+
})
|
|
188
|
+
|
|
189
|
+
// TODO: NullablePermit is marked as nullable in api.json but not in the generated types.
|
|
190
|
+
addToTypeAlias({
|
|
191
|
+
file: nullablePermitFile,
|
|
192
|
+
typeName: 'NullablePermit',
|
|
193
|
+
typeToAdd: '| null',
|
|
194
|
+
})
|
|
195
|
+
|
|
196
|
+
|
|
197
|
+
modifyType({
|
|
198
|
+
file: planResponseFile,
|
|
199
|
+
typeName: 'PlanResponse',
|
|
200
|
+
newProperties: [
|
|
201
|
+
{ name: 'lastUserActionAt', type: 'string', isOptional: true },
|
|
202
|
+
],
|
|
203
|
+
})
|
|
204
|
+
|
|
205
|
+
// Add new enum member
|
|
206
|
+
addEnumMember({ file: routingFile, enumName: 'Routing', newMember: { name: 'JUPITER', value: 'JUPITER' } })
|
|
207
|
+
|
|
208
|
+
// TODO: Check if this was removed from the API. Leaving it in to not break existing code.
|
|
209
|
+
addEnumMember({ file: routingFile, enumName: 'Routing', newMember: { name: 'DUTCH_LIMIT', value: 'DUTCH_LIMIT' }, deprecated: true })
|
|
210
|
+
addEnumMember({ file: orderTypeFile, enumName: 'OrderType', newMember: { name: 'DUTCH', value: 'DUTCH' }, deprecated: true })
|
|
211
|
+
addEnumMember({ file: orderTypeFile, enumName: 'OrderType', newMember: { name: 'DUTCH_LIMIT', value: 'DUTCH_LIMIT' }, deprecated: true })
|
|
212
|
+
addEnumMember({ file: orderStatusFile, enumName: 'OrderStatus', newMember: { name: 'UNVERIFIED', value: 'unverified' }, deprecated: true })
|
|
213
|
+
|
|
214
|
+
|
|
215
|
+
saveFiles({
|
|
216
|
+
files: [
|
|
217
|
+
requestFiles,
|
|
218
|
+
responseFiles,
|
|
219
|
+
planResponseFile,
|
|
220
|
+
routingFile,
|
|
221
|
+
nullablePermitFile,
|
|
222
|
+
orderTypeFile,
|
|
223
|
+
orderStatusFile,
|
|
224
|
+
chainedQuoteFile,
|
|
225
|
+
planStepFile,
|
|
226
|
+
]
|
|
227
|
+
|
|
228
|
+
})
|
|
229
|
+
console.log('Trading API types have been updated')
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
main()
|
package/src/client.ts
ADDED
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { QueryClient } from '@tanstack/react-query'
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Create a React Query client with Lux Exchange defaults
|
|
5
|
+
*/
|
|
6
|
+
export function createQueryClient() {
|
|
7
|
+
return new QueryClient({
|
|
8
|
+
defaultOptions: {
|
|
9
|
+
queries: {
|
|
10
|
+
// 30 seconds stale time by default
|
|
11
|
+
staleTime: 30_000,
|
|
12
|
+
// 5 minutes cache time
|
|
13
|
+
gcTime: 5 * 60 * 1000,
|
|
14
|
+
// Retry failed queries once
|
|
15
|
+
retry: 1,
|
|
16
|
+
// Don't refetch on window focus by default
|
|
17
|
+
refetchOnWindowFocus: false,
|
|
18
|
+
},
|
|
19
|
+
mutations: {
|
|
20
|
+
// Retry mutations once
|
|
21
|
+
retry: 1,
|
|
22
|
+
},
|
|
23
|
+
},
|
|
24
|
+
})
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* API base URLs
|
|
29
|
+
*/
|
|
30
|
+
export const API_URLS = {
|
|
31
|
+
// Token list API
|
|
32
|
+
TOKEN_LIST: 'https://tokens.lux.network',
|
|
33
|
+
|
|
34
|
+
// Price API
|
|
35
|
+
PRICE_API: 'https://api.lux.network/prices',
|
|
36
|
+
|
|
37
|
+
// Analytics API
|
|
38
|
+
ANALYTICS_API: 'https://api.lux.network/analytics',
|
|
39
|
+
|
|
40
|
+
// Subgraph endpoints
|
|
41
|
+
V2_SUBGRAPH: 'https://api.lux.network/subgraphs/exchange-v2',
|
|
42
|
+
V3_SUBGRAPH: 'https://api.lux.network/subgraphs/exchange-v3',
|
|
43
|
+
} as const
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Fetch with timeout
|
|
47
|
+
*/
|
|
48
|
+
export async function fetchWithTimeout(
|
|
49
|
+
url: string,
|
|
50
|
+
options: RequestInit & { timeout?: number } = {}
|
|
51
|
+
): Promise<Response> {
|
|
52
|
+
const { timeout = 10_000, ...fetchOptions } = options
|
|
53
|
+
|
|
54
|
+
const controller = new AbortController()
|
|
55
|
+
const timeoutId = setTimeout(() => controller.abort(), timeout)
|
|
56
|
+
|
|
57
|
+
try {
|
|
58
|
+
const response = await fetch(url, {
|
|
59
|
+
...fetchOptions,
|
|
60
|
+
signal: controller.signal,
|
|
61
|
+
})
|
|
62
|
+
return response
|
|
63
|
+
} finally {
|
|
64
|
+
clearTimeout(timeoutId)
|
|
65
|
+
}
|
|
66
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { PromiseClient } from '@connectrpc/connect'
|
|
2
|
+
import { AuctionService } from '@uniswap/client-data-api/dist/data/v1/auction_connect'
|
|
3
|
+
import {
|
|
4
|
+
GetAuctionActivityRequest,
|
|
5
|
+
GetAuctionActivityResponse,
|
|
6
|
+
GetAuctionRequest,
|
|
7
|
+
GetAuctionResponse,
|
|
8
|
+
GetBidsByWalletRequest,
|
|
9
|
+
GetBidsByWalletResponse,
|
|
10
|
+
GetBidsRequest,
|
|
11
|
+
GetBidsResponse,
|
|
12
|
+
GetClearingPriceHistoryRequest,
|
|
13
|
+
GetClearingPriceHistoryResponse,
|
|
14
|
+
GetLatestCheckpointRequest,
|
|
15
|
+
GetLatestCheckpointResponse,
|
|
16
|
+
ListTopAuctionsRequest,
|
|
17
|
+
ListTopAuctionsResponse,
|
|
18
|
+
} from '@uniswap/client-data-api/dist/data/v1/auction_pb'
|
|
19
|
+
|
|
20
|
+
interface AuctionServiceClientContext {
|
|
21
|
+
rpcClient: PromiseClient<typeof AuctionService>
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export interface AuctionServiceClient {
|
|
25
|
+
getAuction: (params: GetAuctionRequest) => Promise<GetAuctionResponse>
|
|
26
|
+
getAuctionActivity: (params: GetAuctionActivityRequest) => Promise<GetAuctionActivityResponse>
|
|
27
|
+
getBids: (params: GetBidsRequest) => Promise<GetBidsResponse>
|
|
28
|
+
getBidsByWallet: (params: GetBidsByWalletRequest) => Promise<GetBidsByWalletResponse>
|
|
29
|
+
getClearingPriceHistory: (params: GetClearingPriceHistoryRequest) => Promise<GetClearingPriceHistoryResponse>
|
|
30
|
+
getLatestCheckpoint: (params: GetLatestCheckpointRequest) => Promise<GetLatestCheckpointResponse>
|
|
31
|
+
listTopAuctions: (params: ListTopAuctionsRequest) => Promise<ListTopAuctionsResponse>
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export function createAuctionServiceClient({ rpcClient }: AuctionServiceClientContext): AuctionServiceClient {
|
|
35
|
+
return {
|
|
36
|
+
getAuction: (params) => rpcClient.getAuction(params),
|
|
37
|
+
getAuctionActivity: (params) => rpcClient.getAuctionActivity(params),
|
|
38
|
+
getBids: (params) => rpcClient.getBids(params),
|
|
39
|
+
getBidsByWallet: (params) => rpcClient.getBidsByWallet(params),
|
|
40
|
+
getClearingPriceHistory: (params) => rpcClient.getClearingPriceHistory(params),
|
|
41
|
+
getLatestCheckpoint: (params) => rpcClient.getLatestCheckpoint(params),
|
|
42
|
+
listTopAuctions: (params) => rpcClient.listTopAuctions(params),
|
|
43
|
+
}
|
|
44
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { QueryClient } from '@tanstack/react-query'
|
|
2
|
+
import { FetchError } from '@luxfi/api/src/clients/base/errors'
|
|
3
|
+
import { hashKey } from '@luxfi/utilities/src/reactQuery/hashKey'
|
|
4
|
+
import { ONE_DAY_MS, ONE_SECOND_MS } from '@luxfi/utilities/src/time/time'
|
|
5
|
+
|
|
6
|
+
export const SharedQueryClient = new QueryClient({
|
|
7
|
+
defaultOptions: {
|
|
8
|
+
queries: {
|
|
9
|
+
// Ideally, these default values should never be used.
|
|
10
|
+
// Each query should set its own `staleTime` and `gcTime` depending on how often the data is expected to change,
|
|
11
|
+
// and how important it is to keep the data fresh every time a component mounts.
|
|
12
|
+
staleTime: 15 * ONE_SECOND_MS,
|
|
13
|
+
gcTime: ONE_DAY_MS,
|
|
14
|
+
// Retry once, only if the error is a 500 fetch error.
|
|
15
|
+
retry: (failureCount, error): boolean => {
|
|
16
|
+
if (failureCount < 2 && error instanceof FetchError && error.response.status === 500) {
|
|
17
|
+
return true
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
return false
|
|
21
|
+
},
|
|
22
|
+
queryKeyHashFn: hashKey,
|
|
23
|
+
},
|
|
24
|
+
},
|
|
25
|
+
})
|