@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
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import type { FetchClient } from '@luxfi/api/src/clients/base/types'
|
|
2
|
+
import {
|
|
3
|
+
type JupiterExecuteResponse,
|
|
4
|
+
type JupiterExecuteUrlParams,
|
|
5
|
+
type JupiterOrderResponse,
|
|
6
|
+
type JupiterOrderUrlParams,
|
|
7
|
+
jupiterExecuteResponseSchema,
|
|
8
|
+
jupiterOrderResponseSchema,
|
|
9
|
+
} from '@luxfi/api/src/clients/jupiter/types'
|
|
10
|
+
import { buildQuery } from '@luxfi/api/src/clients/jupiter/utils'
|
|
11
|
+
|
|
12
|
+
export interface JupiterApiClient {
|
|
13
|
+
fetchOrder: (params: JupiterOrderUrlParams) => Promise<JupiterOrderResponse>
|
|
14
|
+
execute: (params: JupiterExecuteUrlParams) => Promise<JupiterExecuteResponse>
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export const JUPITER_API_PATHS = {
|
|
18
|
+
order: '/order',
|
|
19
|
+
execute: '/execute',
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export function createJupiterApiClient(ctx: { fetchClient: FetchClient }): JupiterApiClient {
|
|
23
|
+
async function fetchOrder(params: JupiterOrderUrlParams): Promise<JupiterOrderResponse> {
|
|
24
|
+
const query = buildQuery(params)
|
|
25
|
+
const result = await ctx.fetchClient.get(JUPITER_API_PATHS.order + '?' + query.toString())
|
|
26
|
+
|
|
27
|
+
return jupiterOrderResponseSchema.parse(result)
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
async function execute(params: JupiterExecuteUrlParams): Promise<JupiterExecuteResponse> {
|
|
31
|
+
const result = await ctx.fetchClient.post(JUPITER_API_PATHS.execute, {
|
|
32
|
+
body: JSON.stringify(params),
|
|
33
|
+
})
|
|
34
|
+
|
|
35
|
+
return jupiterExecuteResponseSchema.parse(result)
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
return {
|
|
39
|
+
fetchOrder,
|
|
40
|
+
execute,
|
|
41
|
+
}
|
|
42
|
+
}
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import { Prettify } from 'viem'
|
|
2
|
+
import { z } from 'zod'
|
|
3
|
+
|
|
4
|
+
// Input types based on https://dev.jup.ag/docs/api/ultra-api/order, although some are missing from their documentation.
|
|
5
|
+
// Non-documented fields are discoverable via inspecting jup.ag's network requests.
|
|
6
|
+
|
|
7
|
+
export type JupiterOrderUrlParams = {
|
|
8
|
+
inputMint: string
|
|
9
|
+
outputMint: string
|
|
10
|
+
amount: string
|
|
11
|
+
taker?: string
|
|
12
|
+
referralAccount?: string
|
|
13
|
+
referralFee?: string
|
|
14
|
+
slippageBps?: string
|
|
15
|
+
swapMode: 'ExactIn' | 'ExactOut'
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
// Output types derived from https://dev.jup.ag/docs/api/ultra-api/order
|
|
19
|
+
// Some unused fields are commented out for potential future use.
|
|
20
|
+
|
|
21
|
+
const swapInfoSchema = z.looseObject({
|
|
22
|
+
ammKey: z.string().nullish(),
|
|
23
|
+
label: z.string().nullish(),
|
|
24
|
+
inputMint: z.string(),
|
|
25
|
+
outputMint: z.string(),
|
|
26
|
+
})
|
|
27
|
+
|
|
28
|
+
const routePlanSchema = z.array(
|
|
29
|
+
z.looseObject({
|
|
30
|
+
swapInfo: swapInfoSchema,
|
|
31
|
+
percent: z.number(),
|
|
32
|
+
}),
|
|
33
|
+
)
|
|
34
|
+
|
|
35
|
+
const platformFeeSchema = z.looseObject({
|
|
36
|
+
// amount: z.string(), // amount is documented as required but occasionally returns undefined -- we calculate it on our own
|
|
37
|
+
feeBps: z.number().nullish(),
|
|
38
|
+
})
|
|
39
|
+
|
|
40
|
+
const routerTypeSchema = z.string().transform((val) => {
|
|
41
|
+
const normalized = val === 'iris' || val === 'jupiterz' || val === 'dflow' || val === 'okx' ? val : 'unknown'
|
|
42
|
+
return { raw: val, normalized } as const
|
|
43
|
+
})
|
|
44
|
+
|
|
45
|
+
export const jupiterOrderResponseSchema = z.looseObject({
|
|
46
|
+
inputMint: z.string(),
|
|
47
|
+
outputMint: z.string(),
|
|
48
|
+
inAmount: z.string(),
|
|
49
|
+
outAmount: z.string(),
|
|
50
|
+
otherAmountThreshold: z.string(),
|
|
51
|
+
swapMode: z.enum(['ExactIn', 'ExactOut']),
|
|
52
|
+
slippageBps: z.number(),
|
|
53
|
+
priceImpactPct: z.string().nullish(),
|
|
54
|
+
routePlan: routePlanSchema.nullish(),
|
|
55
|
+
// Represents just swap fee
|
|
56
|
+
platformFee: platformFeeSchema.nullish(),
|
|
57
|
+
// feeBps: z.number().nullish(), // `response.feeBps` represents total fee (for example, swap fee + fee for gasless support); currently we use `response.platformFee` to get the swap fee and ignore gasless support fee specifics.
|
|
58
|
+
feeMint: z.string().nullish(),
|
|
59
|
+
prioritizationFeeLamports: z.number(),
|
|
60
|
+
router: routerTypeSchema,
|
|
61
|
+
transaction: z.string().nullish(),
|
|
62
|
+
gasless: z.boolean().nullish(),
|
|
63
|
+
requestId: z.string(),
|
|
64
|
+
// totalTime: z.number(),
|
|
65
|
+
taker: z.string().nullish(),
|
|
66
|
+
quoteId: z.string().nullish(),
|
|
67
|
+
maker: z.string().nullish(),
|
|
68
|
+
// expireAt: z.string().nullish(),
|
|
69
|
+
// dynamicSlippageReport: dynamicSlippageReportSchema.nullish(),
|
|
70
|
+
errorMessage: z.string().nullish(),
|
|
71
|
+
errorCode: z.number().nullish(),
|
|
72
|
+
})
|
|
73
|
+
|
|
74
|
+
export type JupiterOrderResponse = Prettify<z.infer<typeof jupiterOrderResponseSchema>>
|
|
75
|
+
|
|
76
|
+
// Types derived from https://dev.jup.ag/docs/api/ultra-api/execute
|
|
77
|
+
|
|
78
|
+
const StatusEnum = z.enum(['Success', 'Failed'])
|
|
79
|
+
|
|
80
|
+
export const jupiterExecuteResponseSchema = z.looseObject({
|
|
81
|
+
status: StatusEnum,
|
|
82
|
+
signature: z.string().nullish(),
|
|
83
|
+
error: z.string().nullish(),
|
|
84
|
+
code: z.number(),
|
|
85
|
+
})
|
|
86
|
+
|
|
87
|
+
export type JupiterExecuteResponse = z.infer<typeof jupiterExecuteResponseSchema>
|
|
88
|
+
|
|
89
|
+
export type JupiterExecuteUrlParams = {
|
|
90
|
+
signedTransaction: string
|
|
91
|
+
requestId: string
|
|
92
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { JupiterOrderUrlParams } from '@luxfi/api/src/clients/jupiter/types'
|
|
2
|
+
|
|
3
|
+
export function buildQuery(params: JupiterOrderUrlParams): URLSearchParams {
|
|
4
|
+
const query = new URLSearchParams()
|
|
5
|
+
|
|
6
|
+
query.set('inputMint', params.inputMint)
|
|
7
|
+
|
|
8
|
+
query.set('outputMint', params.outputMint)
|
|
9
|
+
|
|
10
|
+
query.set('amount', params.amount.toString())
|
|
11
|
+
|
|
12
|
+
query.set('swapMode', params.swapMode)
|
|
13
|
+
|
|
14
|
+
if (params.taker) {
|
|
15
|
+
query.set('taker', params.taker)
|
|
16
|
+
}
|
|
17
|
+
if (params.referralAccount) {
|
|
18
|
+
query.set('referralAccount', params.referralAccount)
|
|
19
|
+
}
|
|
20
|
+
if (params.referralFee) {
|
|
21
|
+
query.set('referralFee', params.referralFee.toString())
|
|
22
|
+
}
|
|
23
|
+
if (params.slippageBps) {
|
|
24
|
+
query.set('slippageBps', params.slippageBps.toString())
|
|
25
|
+
}
|
|
26
|
+
return query
|
|
27
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { type PartialMessage } from '@bufbuild/protobuf'
|
|
2
|
+
import { type PromiseClient } from '@connectrpc/connect'
|
|
3
|
+
import { type AuctionService } from '@uniswap/client-liquidity/dist/uniswap/liquidity/v1/auction_connect'
|
|
4
|
+
import type {
|
|
5
|
+
ExitBidAndClaimTokensRequest,
|
|
6
|
+
ExitBidAndClaimTokensResponse,
|
|
7
|
+
ExitBidPositionRequest,
|
|
8
|
+
ExitBidPositionResponse,
|
|
9
|
+
SubmitBidRequest,
|
|
10
|
+
SubmitBidResponse,
|
|
11
|
+
TokenCountAllocatedToLpForAuctionRequest,
|
|
12
|
+
TokenCountAllocatedToLpForAuctionResponse,
|
|
13
|
+
VerifyWalletRequest,
|
|
14
|
+
VerifyWalletResponse,
|
|
15
|
+
} from '@uniswap/client-liquidity/dist/uniswap/liquidity/v1/auction_pb'
|
|
16
|
+
|
|
17
|
+
interface AuctionMutationClientContext {
|
|
18
|
+
rpcClient: PromiseClient<typeof AuctionService>
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export interface AuctionMutationClient {
|
|
22
|
+
submitBid: (params: PartialMessage<SubmitBidRequest>) => Promise<SubmitBidResponse>
|
|
23
|
+
exitBidAndClaimTokens: (
|
|
24
|
+
params: PartialMessage<ExitBidAndClaimTokensRequest>,
|
|
25
|
+
) => Promise<ExitBidAndClaimTokensResponse>
|
|
26
|
+
exitBidPosition: (params: PartialMessage<ExitBidPositionRequest>) => Promise<ExitBidPositionResponse>
|
|
27
|
+
tokenCountAllocatedToLpForAuction: (
|
|
28
|
+
params: PartialMessage<TokenCountAllocatedToLpForAuctionRequest>,
|
|
29
|
+
) => Promise<TokenCountAllocatedToLpForAuctionResponse>
|
|
30
|
+
verifyWallet: (params: PartialMessage<VerifyWalletRequest>) => Promise<VerifyWalletResponse>
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export function createAuctionMutationClient({ rpcClient }: AuctionMutationClientContext): AuctionMutationClient {
|
|
34
|
+
return {
|
|
35
|
+
submitBid: (params) => rpcClient.submitBid(params),
|
|
36
|
+
exitBidAndClaimTokens: (params) => rpcClient.exitBidAndClaimTokens(params),
|
|
37
|
+
exitBidPosition: (params) => rpcClient.exitBidPosition(params),
|
|
38
|
+
tokenCountAllocatedToLpForAuction: (params) => rpcClient.tokenCountAllocatedToLpForAuction(params),
|
|
39
|
+
verifyWallet: (params) => rpcClient.verifyWallet(params),
|
|
40
|
+
}
|
|
41
|
+
}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { type PromiseClient } from '@connectrpc/connect'
|
|
2
|
+
import { type LiquidityService } from '@uniswap/client-liquidity/dist/uniswap/liquidity/v1/api_connect'
|
|
3
|
+
import type {
|
|
4
|
+
CheckApprovalLPRequest,
|
|
5
|
+
CheckApprovalLPResponse,
|
|
6
|
+
ClaimLPFeesRequest,
|
|
7
|
+
ClaimLPFeesResponse,
|
|
8
|
+
ClaimLPRewardsRequest,
|
|
9
|
+
ClaimLPRewardsResponse,
|
|
10
|
+
CreateLPPositionRequest,
|
|
11
|
+
CreateLPPositionResponse,
|
|
12
|
+
DecreaseLPPositionRequest,
|
|
13
|
+
DecreaseLPPositionResponse,
|
|
14
|
+
GetLPPriceDiscrepancyRequest,
|
|
15
|
+
GetLPPriceDiscrepancyResponse,
|
|
16
|
+
IncreaseLPPositionRequest,
|
|
17
|
+
IncreaseLPPositionResponse,
|
|
18
|
+
MigrateV2ToV3LPPositionRequest,
|
|
19
|
+
MigrateV2ToV3LPPositionResponse,
|
|
20
|
+
MigrateV3ToV4LPPositionRequest,
|
|
21
|
+
MigrateV3ToV4LPPositionResponse,
|
|
22
|
+
PoolInfoRequest,
|
|
23
|
+
PoolInfoResponse,
|
|
24
|
+
} from '@uniswap/client-liquidity/dist/uniswap/liquidity/v1/api_pb'
|
|
25
|
+
|
|
26
|
+
interface LiquidityServiceClientContext {
|
|
27
|
+
rpcClient: PromiseClient<typeof LiquidityService>
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export interface LiquidityServiceClient {
|
|
31
|
+
checkApproval: (params: CheckApprovalLPRequest) => Promise<CheckApprovalLPResponse>
|
|
32
|
+
claimLpFees: (params: ClaimLPFeesRequest) => Promise<ClaimLPFeesResponse>
|
|
33
|
+
claimRewards: (params: ClaimLPRewardsRequest) => Promise<ClaimLPRewardsResponse>
|
|
34
|
+
createLpPosition: (params: CreateLPPositionRequest) => Promise<CreateLPPositionResponse>
|
|
35
|
+
decreaseLpPosition: (params: DecreaseLPPositionRequest) => Promise<DecreaseLPPositionResponse>
|
|
36
|
+
getLPPriceDiscrepancy: (params: GetLPPriceDiscrepancyRequest) => Promise<GetLPPriceDiscrepancyResponse>
|
|
37
|
+
increaseLpPosition: (params: IncreaseLPPositionRequest) => Promise<IncreaseLPPositionResponse>
|
|
38
|
+
migrateV2ToV3LpPosition: (params: MigrateV2ToV3LPPositionRequest) => Promise<MigrateV2ToV3LPPositionResponse>
|
|
39
|
+
migrateV3ToV4LpPosition: (params: MigrateV3ToV4LPPositionRequest) => Promise<MigrateV3ToV4LPPositionResponse>
|
|
40
|
+
poolInfo: (params: PoolInfoRequest) => Promise<PoolInfoResponse>
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export function createLiquidityServiceClient({ rpcClient }: LiquidityServiceClientContext): LiquidityServiceClient {
|
|
44
|
+
return {
|
|
45
|
+
checkApproval: (params) => rpcClient.checkLPApproval(params),
|
|
46
|
+
claimLpFees: (params) => rpcClient.claimLPFees(params),
|
|
47
|
+
claimRewards: (params) => rpcClient.claimLPRewards(params),
|
|
48
|
+
createLpPosition: (params) => rpcClient.createLPPosition(params),
|
|
49
|
+
decreaseLpPosition: (params) => rpcClient.decreaseLPPosition(params),
|
|
50
|
+
getLPPriceDiscrepancy: (params) => rpcClient.getLPPriceDiscrepancy(params),
|
|
51
|
+
increaseLpPosition: (params) => rpcClient.increaseLPPosition(params),
|
|
52
|
+
migrateV2ToV3LpPosition: (params) => rpcClient.migrateV2ToV3LPPosition(params),
|
|
53
|
+
migrateV3ToV4LpPosition: (params) => rpcClient.migrateV3ToV4LPPosition(params),
|
|
54
|
+
poolInfo: (params) => rpcClient.poolInfo(params),
|
|
55
|
+
}
|
|
56
|
+
}
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import type { TransactionRequest } from '@ethersproject/providers'
|
|
2
|
+
import type { FetchClient } from '@luxexchange/api/src/clients/base/types'
|
|
3
|
+
import {
|
|
4
|
+
type GasFeeResponse,
|
|
5
|
+
type GasFeeResultWithoutState,
|
|
6
|
+
type GasStrategy,
|
|
7
|
+
} from '@luxexchange/api/src/clients/trading/types'
|
|
8
|
+
import { isWebApp } from '@luxfi/utilities/src/platform'
|
|
9
|
+
|
|
10
|
+
// TODO(app-infra), de-duplicate with luxUrls when other consumers are migrated to use this client
|
|
11
|
+
const LUX_API_PATHS = {
|
|
12
|
+
gasFee: '/v1/gas-fee',
|
|
13
|
+
trmScreen: '/v1/screen',
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
type FetchGasFn = ({
|
|
17
|
+
tx,
|
|
18
|
+
fallbackGasLimit,
|
|
19
|
+
}: {
|
|
20
|
+
tx: TransactionRequest
|
|
21
|
+
gasStrategy: GasStrategy
|
|
22
|
+
fallbackGasLimit?: number
|
|
23
|
+
smartContractDelegationAddress?: Address
|
|
24
|
+
}) => Promise<GasFeeResultWithoutState>
|
|
25
|
+
|
|
26
|
+
export type ScreenResponse = {
|
|
27
|
+
block: boolean
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export type ScreenRequest = {
|
|
31
|
+
address: string
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export interface LuxApiClientContext {
|
|
35
|
+
fetchClient: FetchClient
|
|
36
|
+
processGasFeeResponse: (gasFeeResponse: GasFeeResponse, gasStrategy: GasStrategy) => GasFeeResultWithoutState
|
|
37
|
+
estimateGasWithClientSideProvider: (params: {
|
|
38
|
+
tx: TransactionRequest
|
|
39
|
+
fallbackGasLimit?: number
|
|
40
|
+
}) => Promise<GasFeeResultWithoutState>
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export interface LuxApiClient {
|
|
44
|
+
fetchGasFee: FetchGasFn
|
|
45
|
+
fetchTrmScreen: (params: ScreenRequest) => Promise<ScreenResponse>
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
export function createLuxApiClient(ctx: LuxApiClientContext): LuxApiClient {
|
|
49
|
+
const { fetchClient: client, processGasFeeResponse, estimateGasWithClientSideProvider } = ctx
|
|
50
|
+
|
|
51
|
+
const injectGasStrategies = (
|
|
52
|
+
tx: TransactionRequest,
|
|
53
|
+
gasStrategy: GasStrategy,
|
|
54
|
+
): TransactionRequest & { gasStrategies: GasStrategy[] } => {
|
|
55
|
+
return { ...tx, gasStrategies: [gasStrategy] }
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
const injectSmartContractDelegationAddress = (
|
|
59
|
+
tx: TransactionRequest,
|
|
60
|
+
smartContractDelegationAddress?: Address,
|
|
61
|
+
): TransactionRequest => ({
|
|
62
|
+
...tx,
|
|
63
|
+
...(smartContractDelegationAddress ? { smartContractDelegationAddress } : {}),
|
|
64
|
+
})
|
|
65
|
+
|
|
66
|
+
const fetchGasFee: FetchGasFn = async ({ tx, fallbackGasLimit, smartContractDelegationAddress, gasStrategy }) => {
|
|
67
|
+
const txWithScDelegationAddress = injectSmartContractDelegationAddress(tx, smartContractDelegationAddress)
|
|
68
|
+
const body = JSON.stringify(injectGasStrategies(txWithScDelegationAddress, gasStrategy))
|
|
69
|
+
|
|
70
|
+
try {
|
|
71
|
+
const gasFeeResponse = await client.post<GasFeeResponse>(LUX_API_PATHS.gasFee, {
|
|
72
|
+
body,
|
|
73
|
+
headers: smartContractDelegationAddress
|
|
74
|
+
? {
|
|
75
|
+
'x-viem-provider-enabled': 'true',
|
|
76
|
+
}
|
|
77
|
+
: {},
|
|
78
|
+
})
|
|
79
|
+
return processGasFeeResponse(gasFeeResponse, gasStrategy)
|
|
80
|
+
} catch (error) {
|
|
81
|
+
if (isWebApp) {
|
|
82
|
+
// Gas Fee API currently errors on gas estimations on disconnected state & insufficient funds
|
|
83
|
+
// Fallback to clientside estimate using provider.estimateGas
|
|
84
|
+
return estimateGasWithClientSideProvider({ tx, fallbackGasLimit })
|
|
85
|
+
}
|
|
86
|
+
throw error
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
const fetchTrmScreen = async (params: ScreenRequest): Promise<ScreenResponse> => {
|
|
91
|
+
return await client.post<ScreenResponse>(LUX_API_PATHS.trmScreen, {
|
|
92
|
+
body: JSON.stringify(params),
|
|
93
|
+
})
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
return {
|
|
97
|
+
fetchGasFee,
|
|
98
|
+
fetchTrmScreen,
|
|
99
|
+
}
|
|
100
|
+
}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { JsonValue } from '@bufbuild/protobuf'
|
|
2
|
+
import { GetNotificationsResponse as GetNotificationsResponseMessage } from '@uniswap/client-notification-service/dist/uniswap/notificationservice/v1/api_pb'
|
|
3
|
+
import type {
|
|
4
|
+
AckNotificationRequest,
|
|
5
|
+
AckNotificationResponse,
|
|
6
|
+
GetNotificationsRequest,
|
|
7
|
+
GetNotificationsResponse,
|
|
8
|
+
NotificationsApiClient,
|
|
9
|
+
NotificationsClientContext,
|
|
10
|
+
} from '@luxfi/api/src/clients/notifications/types'
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Factory function to create a NotificationsApiClient
|
|
14
|
+
*
|
|
15
|
+
* Example usage:
|
|
16
|
+
* ```typescript
|
|
17
|
+
* const notificationsClient = createNotificationsApiClient({
|
|
18
|
+
* fetchClient: myFetchClient,
|
|
19
|
+
* getApiPathPrefix: () => '/notifications/v1'
|
|
20
|
+
* })
|
|
21
|
+
*
|
|
22
|
+
* const notifications = await notificationsClient.getNotifications()
|
|
23
|
+
* ```
|
|
24
|
+
*
|
|
25
|
+
* @param ctx - Context containing injected dependencies
|
|
26
|
+
* @returns NotificationsApiClient instance
|
|
27
|
+
*/
|
|
28
|
+
export function createNotificationsApiClient(ctx: NotificationsClientContext): NotificationsApiClient {
|
|
29
|
+
const { fetchClient, getApiPathPrefix = (): string => '' } = ctx
|
|
30
|
+
|
|
31
|
+
const getNotifications = async (params?: GetNotificationsRequest): Promise<GetNotificationsResponse> => {
|
|
32
|
+
const pathPrefix = getApiPathPrefix()
|
|
33
|
+
const path = `${pathPrefix}/lux.notificationservice.v1.NotificationService/GetNotifications`
|
|
34
|
+
|
|
35
|
+
try {
|
|
36
|
+
const response = await fetchClient.post<JsonValue>(path, {
|
|
37
|
+
body: JSON.stringify(params ?? {}),
|
|
38
|
+
})
|
|
39
|
+
|
|
40
|
+
return GetNotificationsResponseMessage.fromJson(response, { ignoreUnknownFields: true })
|
|
41
|
+
} catch (error) {
|
|
42
|
+
throw new Error(`Failed to fetch notifications: ${error instanceof Error ? error.message : String(error)}`, {
|
|
43
|
+
cause: error,
|
|
44
|
+
})
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
const ackNotification = async (request: AckNotificationRequest): Promise<AckNotificationResponse> => {
|
|
49
|
+
const pathPrefix = getApiPathPrefix()
|
|
50
|
+
const path = `${pathPrefix}/lux.notificationservice.v1.NotificationService/AckNotifications`
|
|
51
|
+
|
|
52
|
+
try {
|
|
53
|
+
const response = await fetchClient.post<AckNotificationResponse>(path, {
|
|
54
|
+
body: JSON.stringify(request),
|
|
55
|
+
})
|
|
56
|
+
|
|
57
|
+
return response
|
|
58
|
+
} catch (error) {
|
|
59
|
+
throw new Error(
|
|
60
|
+
`Failed to acknowledge notifications: ${error instanceof Error ? error.message : String(error)}`,
|
|
61
|
+
{
|
|
62
|
+
cause: error,
|
|
63
|
+
},
|
|
64
|
+
)
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
return {
|
|
69
|
+
getNotifications,
|
|
70
|
+
ackNotification,
|
|
71
|
+
}
|
|
72
|
+
}
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import type { PlainMessage } from '@bufbuild/protobuf'
|
|
2
|
+
import {
|
|
3
|
+
BackgroundType,
|
|
4
|
+
Button,
|
|
5
|
+
Content,
|
|
6
|
+
ContentStyle,
|
|
7
|
+
Notification,
|
|
8
|
+
OnClickAction,
|
|
9
|
+
AckNotificationRequest as ProtoAckNotificationRequest,
|
|
10
|
+
AckNotificationResponse as ProtoAckNotificationResponse,
|
|
11
|
+
GetNotificationsRequest as ProtoGetNotificationsRequest,
|
|
12
|
+
GetNotificationsResponse as ProtoGetNotificationsResponse,
|
|
13
|
+
} from '@uniswap/client-notification-service/dist/uniswap/notificationservice/v1/api_pb'
|
|
14
|
+
import { FetchClient } from '@luxfi/api/src/clients/base/types'
|
|
15
|
+
|
|
16
|
+
export interface NotificationsClientContext {
|
|
17
|
+
fetchClient: FetchClient
|
|
18
|
+
getApiPathPrefix?: () => string
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Content style types for notifications
|
|
23
|
+
*/
|
|
24
|
+
export { ContentStyle, BackgroundType, OnClickAction }
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Content style type for convenience (union of ContentStyle enum values)
|
|
28
|
+
*/
|
|
29
|
+
export type NotificationContentStyle = ContentStyle
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Button configuration for notification content
|
|
33
|
+
* Re-exported from @l.x/client-notification-service
|
|
34
|
+
* Note: This is the Message class instance, not a plain object.
|
|
35
|
+
* Used within Content which comes from deserialized notifications.
|
|
36
|
+
*/
|
|
37
|
+
export type NotificationButton = Button
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Notification content
|
|
41
|
+
* Re-exported from @l.x/client-notification-service
|
|
42
|
+
*
|
|
43
|
+
* Notification API Type Mapping:
|
|
44
|
+
* - content.title → Modal title
|
|
45
|
+
* - content.subtitle → Modal subtitle
|
|
46
|
+
* - content.background.link → Background image URL (when backgroundType is IMAGE)
|
|
47
|
+
* - content.body.items[] → Feature list with icons and text
|
|
48
|
+
* - content.buttons[] → Action buttons
|
|
49
|
+
*
|
|
50
|
+
* Note: This is the Message class instance, not a plain object.
|
|
51
|
+
* Enum values are numbers at runtime, but toJSON() serializes them as strings.
|
|
52
|
+
*/
|
|
53
|
+
export type NotificationContent = Content
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* In-app notification returned by the notifications API
|
|
57
|
+
* Re-exported from @l.x/client-notification-service
|
|
58
|
+
* Note: This is a plain object (not a Message class instance) to prevent
|
|
59
|
+
* React Query's structural cloning from triggering toJSON() which would
|
|
60
|
+
* convert numeric enum values to strings.
|
|
61
|
+
*/
|
|
62
|
+
export type InAppNotification = PlainMessage<Notification>
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* Request parameters for fetching notifications
|
|
66
|
+
* Re-exported from @l.x/client-notification-service
|
|
67
|
+
*/
|
|
68
|
+
export type GetNotificationsRequest = PlainMessage<ProtoGetNotificationsRequest>
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* Response from the GetNotifications API endpoint
|
|
72
|
+
* Re-exported from @l.x/client-notification-service
|
|
73
|
+
* Note: This is the Message class instance from protobuf deserialization.
|
|
74
|
+
*/
|
|
75
|
+
export type GetNotificationsResponse = ProtoGetNotificationsResponse
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* Request parameters for acknowledging notifications
|
|
79
|
+
* Re-exported from @l.x/client-notification-service
|
|
80
|
+
*/
|
|
81
|
+
export type AckNotificationRequest = PlainMessage<ProtoAckNotificationRequest>
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* Response from the AckNotifications API endpoint
|
|
85
|
+
* Re-exported from @l.x/client-notification-service
|
|
86
|
+
*/
|
|
87
|
+
export type AckNotificationResponse = PlainMessage<ProtoAckNotificationResponse>
|
|
88
|
+
|
|
89
|
+
export interface NotificationsApiClient {
|
|
90
|
+
/**
|
|
91
|
+
* Fetch notifications for the current user
|
|
92
|
+
* Uses session-based authentication (x-session-id header) via FetchClient
|
|
93
|
+
* Returns the raw GetNotificationsResponse message from protobuf deserialization
|
|
94
|
+
*/
|
|
95
|
+
getNotifications: (params?: GetNotificationsRequest) => Promise<GetNotificationsResponse>
|
|
96
|
+
|
|
97
|
+
/**
|
|
98
|
+
* Acknowledge that a notification has been tracked/processed
|
|
99
|
+
* Uses session-based authentication (x-session-id header) via FetchClient
|
|
100
|
+
*/
|
|
101
|
+
ackNotification: (request: AckNotificationRequest) => Promise<AckNotificationResponse>
|
|
102
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/* generated using openapi-typescript-codegen -- do no edit */
|
|
2
|
+
/* istanbul ignore file */
|
|
3
|
+
/* tslint:disable */
|
|
4
|
+
/* eslint-disable */
|
|
5
|
+
import type { ApiRequestOptions } from './ApiRequestOptions';
|
|
6
|
+
import type { ApiResult } from './ApiResult';
|
|
7
|
+
|
|
8
|
+
export class ApiError extends Error {
|
|
9
|
+
public readonly url: string;
|
|
10
|
+
public readonly status: number;
|
|
11
|
+
public readonly statusText: string;
|
|
12
|
+
public readonly body: any;
|
|
13
|
+
public readonly request: ApiRequestOptions;
|
|
14
|
+
|
|
15
|
+
constructor(request: ApiRequestOptions, response: ApiResult, message: string) {
|
|
16
|
+
super(message);
|
|
17
|
+
|
|
18
|
+
this.name = 'ApiError';
|
|
19
|
+
this.url = response.url;
|
|
20
|
+
this.status = response.status;
|
|
21
|
+
this.statusText = response.statusText;
|
|
22
|
+
this.body = response.body;
|
|
23
|
+
this.request = request;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/* generated using openapi-typescript-codegen -- do no edit */
|
|
2
|
+
/* istanbul ignore file */
|
|
3
|
+
/* tslint:disable */
|
|
4
|
+
/* eslint-disable */
|
|
5
|
+
export type ApiRequestOptions = {
|
|
6
|
+
readonly method: 'GET' | 'PUT' | 'POST' | 'DELETE' | 'OPTIONS' | 'HEAD' | 'PATCH';
|
|
7
|
+
readonly url: string;
|
|
8
|
+
readonly path?: Record<string, any>;
|
|
9
|
+
readonly cookies?: Record<string, any>;
|
|
10
|
+
readonly headers?: Record<string, any>;
|
|
11
|
+
readonly query?: Record<string, any>;
|
|
12
|
+
readonly formData?: Record<string, any>;
|
|
13
|
+
readonly body?: any;
|
|
14
|
+
readonly mediaType?: string;
|
|
15
|
+
readonly responseHeader?: string;
|
|
16
|
+
readonly errors?: Record<number, string>;
|
|
17
|
+
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/* generated using openapi-typescript-codegen -- do no edit */
|
|
2
|
+
/* istanbul ignore file */
|
|
3
|
+
/* tslint:disable */
|
|
4
|
+
/* eslint-disable */
|
|
5
|
+
export type ApiResult = {
|
|
6
|
+
readonly url: string;
|
|
7
|
+
readonly ok: boolean;
|
|
8
|
+
readonly status: number;
|
|
9
|
+
readonly statusText: string;
|
|
10
|
+
readonly body: any;
|
|
11
|
+
};
|