@gala-chain/launchpad-sdk 5.0.3 → 5.0.4-beta.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/EXAMPLES.md +141 -7
- package/README.md +68 -36
- package/dist/ai-docs.json +7357 -0
- package/dist/index.cjs.js +1 -1
- package/dist/index.d.ts +70 -11
- package/dist/index.d.ts.map +1 -1
- package/dist/index.esm.js +1 -1
- package/dist/index.js +1 -1
- package/dist/src/LaunchpadSDK.d.ts +3288 -214
- package/dist/src/LaunchpadSDK.d.ts.map +1 -1
- package/dist/src/api/LaunchpadAPI.d.ts +21 -41
- package/dist/src/api/LaunchpadAPI.d.ts.map +1 -1
- package/dist/src/api/dto/BurnTokensDto.d.ts.map +1 -1
- package/dist/src/api/dto/LockTokenDto.d.ts.map +1 -1
- package/dist/src/api/dto/TransferTokenDto.d.ts.map +1 -1
- package/dist/src/api/dto/UnlockTokenDto.d.ts.map +1 -1
- package/dist/src/auth/JwtAuth.d.ts +145 -0
- package/dist/src/auth/JwtAuth.d.ts.map +1 -0
- package/dist/src/auth/SessionAuthService.d.ts +146 -0
- package/dist/src/auth/SessionAuthService.d.ts.map +1 -0
- package/dist/src/auth/SignatureAuth.d.ts.map +1 -1
- package/dist/src/bridge/BridgeService.d.ts.map +1 -1
- package/dist/src/bridge/GalaConnectClient.d.ts.map +1 -1
- package/dist/src/bridge/constants/tokens.d.ts +4 -3
- package/dist/src/bridge/constants/tokens.d.ts.map +1 -1
- package/dist/src/bridge/index.d.ts +1 -0
- package/dist/src/bridge/index.d.ts.map +1 -1
- package/dist/src/bridge/strategies/BridgeStrategy.d.ts.map +1 -1
- package/dist/src/bridge/strategies/EthereumBridgeStrategy.d.ts +1 -38
- package/dist/src/bridge/strategies/EthereumBridgeStrategy.d.ts.map +1 -1
- package/dist/src/bridge/strategies/SolanaBridgeStrategy.d.ts +1 -21
- package/dist/src/bridge/strategies/SolanaBridgeStrategy.d.ts.map +1 -1
- package/dist/src/bridge/types/bridge.dto.d.ts +15 -2
- package/dist/src/bridge/types/bridge.dto.d.ts.map +1 -1
- package/dist/src/bridge/utils/RateLimiter.d.ts +1 -1
- package/dist/src/bridge/utils/RateLimiter.d.ts.map +1 -1
- package/dist/src/bridge/utils/address-formatter.d.ts +25 -0
- package/dist/src/bridge/utils/address-formatter.d.ts.map +1 -0
- package/dist/src/bridge/utils/addressValidation.d.ts +200 -0
- package/dist/src/bridge/utils/addressValidation.d.ts.map +1 -0
- package/dist/src/bridge/utils/balanceHelpers.d.ts +215 -0
- package/dist/src/bridge/utils/balanceHelpers.d.ts.map +1 -0
- package/dist/src/bridge/utils/bridgeErrors.d.ts +98 -0
- package/dist/src/bridge/utils/bridgeErrors.d.ts.map +1 -0
- package/dist/src/bridge/utils/bridgeOutHelpers.d.ts +68 -0
- package/dist/src/bridge/utils/bridgeOutHelpers.d.ts.map +1 -0
- package/dist/src/bridge/utils/bridgePayload.d.ts +107 -0
- package/dist/src/bridge/utils/bridgePayload.d.ts.map +1 -0
- package/dist/src/bridge/utils/bridgeStatusParser.d.ts +75 -0
- package/dist/src/bridge/utils/bridgeStatusParser.d.ts.map +1 -0
- package/dist/src/bridge/utils/eip712Helpers.d.ts +66 -0
- package/dist/src/bridge/utils/eip712Helpers.d.ts.map +1 -0
- package/dist/src/bridge/utils/index.d.ts +9 -0
- package/dist/src/bridge/utils/index.d.ts.map +1 -1
- package/dist/src/bridge/utils/retry.d.ts +16 -0
- package/dist/src/bridge/utils/retry.d.ts.map +1 -1
- package/dist/src/bridge/utils/strategyDelegation.d.ts +69 -0
- package/dist/src/bridge/utils/strategyDelegation.d.ts.map +1 -0
- package/dist/src/bridge/utils/tokenIdUtils.d.ts +7 -0
- package/dist/src/bridge/utils/tokenIdUtils.d.ts.map +1 -1
- package/dist/src/bridge/utils/tokenMath.d.ts.map +1 -1
- package/dist/src/bridge/utils/tokenMetadataResolver.d.ts +97 -0
- package/dist/src/bridge/utils/tokenMetadataResolver.d.ts.map +1 -0
- package/dist/src/constants/endpoints.d.ts +453 -0
- package/dist/src/constants/endpoints.d.ts.map +1 -1
- package/dist/src/constants/error-messages.d.ts +1 -1
- package/dist/src/constants/error-messages.d.ts.map +1 -1
- package/dist/src/constants/jwt.d.ts +41 -0
- package/dist/src/constants/jwt.d.ts.map +1 -0
- package/dist/src/constants/sdk-defaults.d.ts +37 -0
- package/dist/src/constants/sdk-defaults.d.ts.map +1 -0
- package/dist/src/constants/version.generated.d.ts +1 -1
- package/dist/src/constants/version.generated.d.ts.map +1 -1
- package/dist/src/helpers/sdk.d.ts.map +1 -1
- package/dist/src/helpers/wallet.d.ts +4 -3
- package/dist/src/helpers/wallet.d.ts.map +1 -1
- package/dist/src/index.d.ts +70 -11
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/schemas/files.d.ts +2 -2
- package/dist/src/schemas/launchpad.d.ts +40 -8
- package/dist/src/schemas/launchpad.d.ts.map +1 -1
- package/dist/src/schemas/pagination.d.ts +7 -7
- package/dist/src/schemas/primitives.d.ts.map +1 -1
- package/dist/src/schemas/trade.d.ts +6 -6
- package/dist/src/schemas/user.d.ts +4 -4
- package/dist/src/schemas/validators.d.ts +15 -7
- package/dist/src/schemas/validators.d.ts.map +1 -1
- package/dist/src/services/AbstractCacheService.d.ts +227 -0
- package/dist/src/services/AbstractCacheService.d.ts.map +1 -0
- package/dist/src/services/AbstractTokenFetchService.d.ts +150 -0
- package/dist/src/services/AbstractTokenFetchService.d.ts.map +1 -0
- package/dist/src/services/ApiKeyService.d.ts +205 -0
- package/dist/src/services/ApiKeyService.d.ts.map +1 -0
- package/dist/src/services/BanService.d.ts +195 -0
- package/dist/src/services/BanService.d.ts.map +1 -0
- package/dist/src/services/BaseService.d.ts +50 -3
- package/dist/src/services/BaseService.d.ts.map +1 -1
- package/dist/src/services/BatchedCacheService.d.ts +132 -0
- package/dist/src/services/BatchedCacheService.d.ts.map +1 -0
- package/dist/src/services/BridgeableTokenCache.d.ts +32 -98
- package/dist/src/services/BridgeableTokenCache.d.ts.map +1 -1
- package/dist/src/services/BridgeableTokenService.d.ts +18 -13
- package/dist/src/services/BridgeableTokenService.d.ts.map +1 -1
- package/dist/src/services/BundleService.d.ts.map +1 -1
- package/dist/src/services/BundlerClientFactory.d.ts +32 -0
- package/dist/src/services/BundlerClientFactory.d.ts.map +1 -0
- package/dist/src/services/ChatMessagesService.d.ts +152 -0
- package/dist/src/services/ChatMessagesService.d.ts.map +1 -0
- package/dist/src/services/CommentService.d.ts +119 -0
- package/dist/src/services/CommentService.d.ts.map +1 -0
- package/dist/src/services/CommentsService.d.ts +155 -0
- package/dist/src/services/CommentsService.d.ts.map +1 -0
- package/dist/src/services/ContentFlagService.d.ts +212 -0
- package/dist/src/services/ContentFlagService.d.ts.map +1 -0
- package/dist/src/services/ContentReactionService.d.ts +175 -0
- package/dist/src/services/ContentReactionService.d.ts.map +1 -0
- package/dist/src/services/DexBackendClient.d.ts.map +1 -1
- package/dist/src/services/DexPoolService.d.ts +3 -3
- package/dist/src/services/DexPoolService.d.ts.map +1 -1
- package/dist/src/services/DexQuoteService.d.ts.map +1 -1
- package/dist/src/services/DexService.d.ts +2 -5
- package/dist/src/services/DexService.d.ts.map +1 -1
- package/dist/src/services/GSwapAssetService.d.ts +80 -0
- package/dist/src/services/GSwapAssetService.d.ts.map +1 -0
- package/dist/src/services/GSwapLiquidityMutationService.d.ts +140 -0
- package/dist/src/services/GSwapLiquidityMutationService.d.ts.map +1 -0
- package/dist/src/services/GSwapLiquidityQueryService.d.ts +87 -0
- package/dist/src/services/GSwapLiquidityQueryService.d.ts.map +1 -0
- package/dist/src/services/GSwapPoolCalculationService.d.ts +200 -0
- package/dist/src/services/GSwapPoolCalculationService.d.ts.map +1 -0
- package/dist/src/services/GSwapPoolQueryService.d.ts +116 -0
- package/dist/src/services/GSwapPoolQueryService.d.ts.map +1 -0
- package/dist/src/services/GSwapService.d.ts +14 -0
- package/dist/src/services/GSwapService.d.ts.map +1 -1
- package/dist/src/services/GSwapSwapService.d.ts +68 -0
- package/dist/src/services/GSwapSwapService.d.ts.map +1 -0
- package/dist/src/services/GalaChainBalanceService.d.ts +155 -0
- package/dist/src/services/GalaChainBalanceService.d.ts.map +1 -0
- package/dist/src/services/GalaChainGatewayClient.d.ts +32 -1
- package/dist/src/services/GalaChainGatewayClient.d.ts.map +1 -1
- package/dist/src/services/GalaChainLockService.d.ts +144 -0
- package/dist/src/services/GalaChainLockService.d.ts.map +1 -0
- package/dist/src/services/GalaChainService.d.ts +23 -106
- package/dist/src/services/GalaChainService.d.ts.map +1 -1
- package/dist/src/services/GalaChainTokenService.d.ts +108 -0
- package/dist/src/services/GalaChainTokenService.d.ts.map +1 -0
- package/dist/src/services/GalaChainTransferService.d.ts +205 -0
- package/dist/src/services/GalaChainTransferService.d.ts.map +1 -0
- package/dist/src/services/ImageService.d.ts +24 -8
- package/dist/src/services/ImageService.d.ts.map +1 -1
- package/dist/src/services/LaunchpadService.d.ts +77 -5
- package/dist/src/services/LaunchpadService.d.ts.map +1 -1
- package/dist/src/services/ModeratorService.d.ts +269 -0
- package/dist/src/services/ModeratorService.d.ts.map +1 -0
- package/dist/src/services/MultiPoolStateManager.d.ts +4 -6
- package/dist/src/services/MultiPoolStateManager.d.ts.map +1 -1
- package/dist/src/services/NetworkKeyedCacheService.d.ts +185 -0
- package/dist/src/services/NetworkKeyedCacheService.d.ts.map +1 -0
- package/dist/src/services/OverseerService.d.ts +322 -0
- package/dist/src/services/OverseerService.d.ts.map +1 -0
- package/dist/src/services/PoolCacheManager.d.ts +2 -2
- package/dist/src/services/PoolCacheManager.d.ts.map +1 -1
- package/dist/src/services/PoolService.d.ts +61 -7
- package/dist/src/services/PoolService.d.ts.map +1 -1
- package/dist/src/services/PoolStateManager.d.ts +2 -2
- package/dist/src/services/PoolStateManager.d.ts.map +1 -1
- package/dist/src/services/PriceHistoryService.d.ts.map +1 -1
- package/dist/src/services/SignatureService.d.ts.map +1 -1
- package/dist/src/services/StreamChatService.d.ts +378 -0
- package/dist/src/services/StreamChatService.d.ts.map +1 -0
- package/dist/src/services/StreamTokenServiceBase.d.ts +371 -0
- package/dist/src/services/StreamTokenServiceBase.d.ts.map +1 -0
- package/dist/src/services/StreamWebSocketService.d.ts +268 -0
- package/dist/src/services/StreamWebSocketService.d.ts.map +1 -0
- package/dist/src/services/StreamingEventService.d.ts +431 -0
- package/dist/src/services/StreamingEventService.d.ts.map +1 -0
- package/dist/src/services/StreamingService.d.ts +547 -0
- package/dist/src/services/StreamingService.d.ts.map +1 -0
- package/dist/src/services/SwapEventQueue.d.ts +2 -2
- package/dist/src/services/SwapEventQueue.d.ts.map +1 -1
- package/dist/src/services/TokenBanService.d.ts +214 -0
- package/dist/src/services/TokenBanService.d.ts.map +1 -0
- package/dist/src/services/TokenClassKeyService.d.ts.map +1 -1
- package/dist/src/services/TokenMetadataCache.d.ts +36 -27
- package/dist/src/services/TokenMetadataCache.d.ts.map +1 -1
- package/dist/src/services/TokenMetadataService.d.ts +24 -4
- package/dist/src/services/TokenMetadataService.d.ts.map +1 -1
- package/dist/src/services/TokenResolverService.d.ts.map +1 -1
- package/dist/src/services/TradeService.d.ts +73 -0
- package/dist/src/services/TradeService.d.ts.map +1 -1
- package/dist/src/services/UserService.d.ts +56 -3
- package/dist/src/services/UserService.d.ts.map +1 -1
- package/dist/src/services/WebSocketService.d.ts +3 -3
- package/dist/src/services/WebSocketService.d.ts.map +1 -1
- package/dist/src/services/WrapService.d.ts +18 -5
- package/dist/src/services/WrapService.d.ts.map +1 -1
- package/dist/src/services/WrappableTokenCache.d.ts +8 -36
- package/dist/src/services/WrappableTokenCache.d.ts.map +1 -1
- package/dist/src/services/WrappableTokenService.d.ts +18 -12
- package/dist/src/services/WrappableTokenService.d.ts.map +1 -1
- package/dist/src/services/shared/cache-helpers.d.ts +188 -0
- package/dist/src/services/shared/cache-helpers.d.ts.map +1 -0
- package/dist/src/services/shared/http-helpers.d.ts +146 -0
- package/dist/src/services/shared/http-helpers.d.ts.map +1 -0
- package/dist/src/services/shared/pagination-helpers.d.ts +157 -0
- package/dist/src/services/shared/pagination-helpers.d.ts.map +1 -0
- package/dist/src/services/shared/service-validators.d.ts +137 -0
- package/dist/src/services/shared/service-validators.d.ts.map +1 -0
- package/dist/src/services/shared/websocket-helpers.d.ts +158 -0
- package/dist/src/services/shared/websocket-helpers.d.ts.map +1 -0
- package/dist/src/test-constants.d.ts +29 -0
- package/dist/src/test-constants.d.ts.map +1 -0
- package/dist/src/types/api-key.dto.d.ts +300 -0
- package/dist/src/types/api-key.dto.d.ts.map +1 -0
- package/dist/src/types/backend-responses.d.ts +12 -0
- package/dist/src/types/backend-responses.d.ts.map +1 -1
- package/dist/src/types/ban.dto.d.ts +413 -0
- package/dist/src/types/ban.dto.d.ts.map +1 -0
- package/dist/src/types/burn.dto.d.ts +21 -0
- package/dist/src/types/burn.dto.d.ts.map +1 -1
- package/dist/src/types/chat-messages.dto.d.ts +193 -0
- package/dist/src/types/chat-messages.dto.d.ts.map +1 -0
- package/dist/src/types/comment.dto.d.ts +180 -0
- package/dist/src/types/comment.dto.d.ts.map +1 -0
- package/dist/src/types/comments.dto.d.ts +210 -0
- package/dist/src/types/comments.dto.d.ts.map +1 -0
- package/dist/src/types/common.d.ts +369 -0
- package/dist/src/types/common.d.ts.map +1 -1
- package/dist/src/types/constraints.d.ts +374 -0
- package/dist/src/types/constraints.d.ts.map +1 -0
- package/dist/src/types/content-flag.dto.d.ts +310 -0
- package/dist/src/types/content-flag.dto.d.ts.map +1 -0
- package/dist/src/types/content-reactions.dto.d.ts +132 -0
- package/dist/src/types/content-reactions.dto.d.ts.map +1 -0
- package/dist/src/types/dex-pool.dto.d.ts +13 -37
- package/dist/src/types/dex-pool.dto.d.ts.map +1 -1
- package/dist/src/types/dto.d.ts +8 -0
- package/dist/src/types/dto.d.ts.map +1 -1
- package/dist/src/types/galachain-api.types.d.ts +30 -0
- package/dist/src/types/galachain-api.types.d.ts.map +1 -1
- package/dist/src/types/gswap-responses.types.d.ts.map +1 -1
- package/dist/src/types/launchpad.dto.d.ts +234 -131
- package/dist/src/types/launchpad.dto.d.ts.map +1 -1
- package/dist/src/types/launchpad.validation.d.ts.map +1 -1
- package/dist/src/types/lock.dto.d.ts +20 -35
- package/dist/src/types/lock.dto.d.ts.map +1 -1
- package/dist/src/types/moderator.dto.d.ts +581 -0
- package/dist/src/types/moderator.dto.d.ts.map +1 -0
- package/dist/src/types/options.dto.d.ts +25 -115
- package/dist/src/types/options.dto.d.ts.map +1 -1
- package/dist/src/types/overseer.dto.d.ts +420 -0
- package/dist/src/types/overseer.dto.d.ts.map +1 -0
- package/dist/src/types/pool.dto.d.ts +106 -0
- package/dist/src/types/pool.dto.d.ts.map +1 -0
- package/dist/src/types/result.types.d.ts +3 -2
- package/dist/src/types/result.types.d.ts.map +1 -1
- package/dist/src/types/session-auth.dto.d.ts +91 -0
- package/dist/src/types/session-auth.dto.d.ts.map +1 -0
- package/dist/src/types/stream-chat.dto.d.ts +815 -0
- package/dist/src/types/stream-chat.dto.d.ts.map +1 -0
- package/dist/src/types/streaming-events.dto.d.ts +586 -0
- package/dist/src/types/streaming-events.dto.d.ts.map +1 -0
- package/dist/src/types/streaming.dto.d.ts +1141 -0
- package/dist/src/types/streaming.dto.d.ts.map +1 -0
- package/dist/src/types/token-ban.dto.d.ts +195 -0
- package/dist/src/types/token-ban.dto.d.ts.map +1 -0
- package/dist/src/types/trade.dto.d.ts +21 -61
- package/dist/src/types/trade.dto.d.ts.map +1 -1
- package/dist/src/types/trades-query.dto.d.ts +127 -0
- package/dist/src/types/trades-query.dto.d.ts.map +1 -0
- package/dist/src/types/transfer.dto.d.ts +20 -15
- package/dist/src/types/transfer.dto.d.ts.map +1 -1
- package/dist/src/types/user.dto.d.ts +185 -73
- package/dist/src/types/user.dto.d.ts.map +1 -1
- package/dist/src/types/wrappable-token.dto.d.ts +6 -2
- package/dist/src/types/wrappable-token.dto.d.ts.map +1 -1
- package/dist/src/utils/LiquidityEventExtractor.d.ts.map +1 -1
- package/dist/src/utils/Logger.d.ts.map +1 -1
- package/dist/src/utils/MonitoringMetrics.d.ts.map +1 -1
- package/dist/src/utils/PoolKeyNormalizer.d.ts.map +1 -1
- package/dist/src/utils/ReconnectionManager.d.ts +142 -0
- package/dist/src/utils/ReconnectionManager.d.ts.map +1 -0
- package/dist/src/utils/SignatureHelper.d.ts +9 -0
- package/dist/src/utils/SignatureHelper.d.ts.map +1 -1
- package/dist/src/utils/SwapEventExtractor.d.ts.map +1 -1
- package/dist/src/utils/adapters.d.ts.map +1 -1
- package/dist/src/utils/address-formatter.d.ts +317 -0
- package/dist/src/utils/address-formatter.d.ts.map +1 -0
- package/dist/src/utils/agent-config.d.ts.map +1 -1
- package/dist/src/utils/amount-validator.d.ts +268 -0
- package/dist/src/utils/amount-validator.d.ts.map +1 -0
- package/dist/src/utils/api-patterns.d.ts +347 -0
- package/dist/src/utils/api-patterns.d.ts.map +1 -0
- package/dist/src/utils/array-helpers.d.ts +115 -0
- package/dist/src/utils/array-helpers.d.ts.map +1 -0
- package/dist/src/utils/async-patterns.d.ts +272 -0
- package/dist/src/utils/async-patterns.d.ts.map +1 -0
- package/dist/src/utils/auto-pagination.d.ts +195 -2
- package/dist/src/utils/auto-pagination.d.ts.map +1 -1
- package/dist/src/utils/bignumber-helpers.d.ts +119 -13
- package/dist/src/utils/bignumber-helpers.d.ts.map +1 -1
- package/dist/src/utils/bignumber-pool-cache.d.ts.map +1 -1
- package/dist/src/utils/bondingCurveCalculations.d.ts.map +1 -1
- package/dist/src/utils/cacheWarmingHelpers.d.ts +2 -2
- package/dist/src/utils/cacheWarmingHelpers.d.ts.map +1 -1
- package/dist/src/utils/data-transform-patterns.d.ts +393 -0
- package/dist/src/utils/data-transform-patterns.d.ts.map +1 -0
- package/dist/src/utils/date-utils.d.ts +166 -0
- package/dist/src/utils/date-utils.d.ts.map +1 -1
- package/dist/src/utils/delimiter-parser.d.ts +139 -0
- package/dist/src/utils/delimiter-parser.d.ts.map +1 -0
- package/dist/src/utils/error-factories.d.ts +346 -1
- package/dist/src/utils/error-factories.d.ts.map +1 -1
- package/dist/src/utils/error-handling-patterns.d.ts +390 -0
- package/dist/src/utils/error-handling-patterns.d.ts.map +1 -0
- package/dist/src/utils/error-patterns.d.ts +360 -0
- package/dist/src/utils/error-patterns.d.ts.map +1 -0
- package/dist/src/utils/error-utils.d.ts +250 -0
- package/dist/src/utils/error-utils.d.ts.map +1 -1
- package/dist/src/utils/error-wrapper.d.ts +208 -0
- package/dist/src/utils/error-wrapper.d.ts.map +1 -0
- package/dist/src/utils/errors.d.ts +70 -0
- package/dist/src/utils/errors.d.ts.map +1 -1
- package/dist/src/utils/http-factory.d.ts +36 -0
- package/dist/src/utils/http-factory.d.ts.map +1 -0
- package/dist/src/utils/http.d.ts.map +1 -1
- package/dist/src/utils/load-env.d.ts.map +1 -1
- package/dist/src/utils/multipart.d.ts.map +1 -1
- package/dist/src/utils/numeric-patterns.d.ts +289 -0
- package/dist/src/utils/numeric-patterns.d.ts.map +1 -0
- package/dist/src/utils/numeric-wrappers.d.ts +146 -0
- package/dist/src/utils/numeric-wrappers.d.ts.map +1 -0
- package/dist/src/utils/object-extractors.d.ts +115 -0
- package/dist/src/utils/object-extractors.d.ts.map +1 -0
- package/dist/src/utils/object-patterns.d.ts +81 -0
- package/dist/src/utils/object-patterns.d.ts.map +1 -0
- package/dist/src/utils/pagination-helpers.d.ts +230 -0
- package/dist/src/utils/pagination-helpers.d.ts.map +1 -0
- package/dist/src/utils/pool-pair-parser.d.ts +3 -1
- package/dist/src/utils/pool-pair-parser.d.ts.map +1 -1
- package/dist/src/utils/pool-state-validator.d.ts.map +1 -1
- package/dist/src/utils/position-filters.d.ts +1 -2
- package/dist/src/utils/position-filters.d.ts.map +1 -1
- package/dist/src/utils/query-params.d.ts +0 -16
- package/dist/src/utils/query-params.d.ts.map +1 -1
- package/dist/src/utils/response-handlers.d.ts +149 -20
- package/dist/src/utils/response-handlers.d.ts.map +1 -1
- package/dist/src/utils/response-helpers.d.ts +28 -0
- package/dist/src/utils/response-helpers.d.ts.map +1 -0
- package/dist/src/utils/response-normalizers.d.ts +27 -49
- package/dist/src/utils/response-normalizers.d.ts.map +1 -1
- package/dist/src/utils/safe-parsers.d.ts +487 -0
- package/dist/src/utils/safe-parsers.d.ts.map +1 -0
- package/dist/src/utils/service-validators.d.ts +268 -0
- package/dist/src/utils/service-validators.d.ts.map +1 -0
- package/dist/src/utils/slippage-utils.d.ts.map +1 -1
- package/dist/src/utils/string-patterns.d.ts +404 -0
- package/dist/src/utils/string-patterns.d.ts.map +1 -0
- package/dist/src/utils/string-transforms.d.ts +89 -0
- package/dist/src/utils/string-transforms.d.ts.map +1 -0
- package/dist/src/utils/string-utils.d.ts +108 -0
- package/dist/src/utils/string-utils.d.ts.map +1 -0
- package/dist/src/utils/swap-delta-calculator.d.ts.map +1 -1
- package/dist/src/utils/tick-crossing-handler.d.ts.map +1 -1
- package/dist/src/utils/token-format-converter.d.ts +22 -8
- package/dist/src/utils/token-format-converter.d.ts.map +1 -1
- package/dist/src/utils/token-parser.d.ts +2 -2
- package/dist/src/utils/token-parser.d.ts.map +1 -1
- package/dist/src/utils/token-stringification.d.ts +168 -0
- package/dist/src/utils/token-stringification.d.ts.map +1 -0
- package/dist/src/utils/tokenNameNormalizer.d.ts +96 -0
- package/dist/src/utils/tokenNameNormalizer.d.ts.map +1 -0
- package/dist/src/utils/tokenNormalizer.d.ts +8 -45
- package/dist/src/utils/tokenNormalizer.d.ts.map +1 -1
- package/dist/src/utils/transfer-validation.d.ts +1 -1
- package/dist/src/utils/transfer-validation.d.ts.map +1 -1
- package/dist/src/utils/type-guard-factory.d.ts +260 -0
- package/dist/src/utils/type-guard-factory.d.ts.map +1 -0
- package/dist/src/utils/unique-key-generator.d.ts +148 -0
- package/dist/src/utils/unique-key-generator.d.ts.map +1 -0
- package/dist/src/utils/validation-helpers.d.ts +906 -183
- package/dist/src/utils/validation-helpers.d.ts.map +1 -1
- package/dist/src/utils/validation-patterns.d.ts +745 -0
- package/dist/src/utils/validation-patterns.d.ts.map +1 -0
- package/dist/src/utils/validation.d.ts +2 -30
- package/dist/src/utils/validation.d.ts.map +1 -1
- package/dist/src/utils/wallet.d.ts +12 -1
- package/dist/src/utils/wallet.d.ts.map +1 -1
- package/dist/src/utils/websocket-patterns.d.ts +681 -0
- package/dist/src/utils/websocket-patterns.d.ts.map +1 -0
- package/dist/src/utils/websocket-validators.d.ts.map +1 -1
- package/package.json +86 -19
- package/dist/src/bridge/strategies/index.d.ts +0 -9
- package/dist/src/bridge/strategies/index.d.ts.map +0 -1
- package/dist/src/constants/counts.d.ts +0 -66
- package/dist/src/constants/counts.d.ts.map +0 -1
- package/dist/src/services/WebSocketManager.d.ts +0 -99
- package/dist/src/services/WebSocketManager.d.ts.map +0 -1
- package/dist/src/types/eip712-types.d.ts +0 -140
- package/dist/src/types/eip712-types.d.ts.map +0 -1
- package/dist/src/types/pool-state-manager-config.dto.d.ts +0 -103
- package/dist/src/types/pool-state-manager-config.dto.d.ts.map +0 -1
- package/dist/src/utils/number-utils.d.ts +0 -94
- package/dist/src/utils/number-utils.d.ts.map +0 -1
- package/dist/src/utils/precision-math.d.ts +0 -37
- package/dist/src/utils/precision-math.d.ts.map +0 -1
|
@@ -0,0 +1,745 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Common Validation Patterns for Launchpad SDK
|
|
3
|
+
*
|
|
4
|
+
* Reusable validation utilities that consolidate duplicate patterns
|
|
5
|
+
* found across services and DTOs. Eliminates boilerplate validation code
|
|
6
|
+
* and provides consistent error messages throughout the SDK.
|
|
7
|
+
*
|
|
8
|
+
* @category Utilities
|
|
9
|
+
* @since 6.20.0
|
|
10
|
+
*/
|
|
11
|
+
/**
|
|
12
|
+
* Validates numeric values within inclusive bounds (min ≤ value ≤ max)
|
|
13
|
+
*
|
|
14
|
+
* Consolidates 7 instances of numeric range validation found in:
|
|
15
|
+
* - pagination-helpers.ts (page, limit bounds)
|
|
16
|
+
* - dex-service.ts (limit, offset constraints)
|
|
17
|
+
* - liquidity-service.ts (slippage tolerance bounds)
|
|
18
|
+
*
|
|
19
|
+
* ## Replaces Pattern
|
|
20
|
+
*
|
|
21
|
+
* ### Before (Duplicate across services):
|
|
22
|
+
* ```typescript
|
|
23
|
+
* if (page < MIN_PAGE || page > MAX_PAGE) {
|
|
24
|
+
* throw new ValidationError(`Page must be between ${MIN_PAGE} and ${MAX_PAGE}`, 'page');
|
|
25
|
+
* }
|
|
26
|
+
* ```
|
|
27
|
+
*
|
|
28
|
+
* ### After (Single call):
|
|
29
|
+
* ```typescript
|
|
30
|
+
* numericRangeValidation(page, MIN_PAGE, MAX_PAGE, 'page');
|
|
31
|
+
* ```
|
|
32
|
+
*
|
|
33
|
+
* @param value The numeric value to validate
|
|
34
|
+
* @param min Minimum allowed value (inclusive)
|
|
35
|
+
* @param max Maximum allowed value (inclusive)
|
|
36
|
+
* @param fieldName Field name for error messages (e.g., 'page', 'slippageTolerance')
|
|
37
|
+
* @throws {ValidationError} If value is not a number or outside bounds
|
|
38
|
+
*
|
|
39
|
+
* @example Basic pagination validation
|
|
40
|
+
* ```typescript
|
|
41
|
+
* import { numericRangeValidation } from '../utils/validation-patterns';
|
|
42
|
+
*
|
|
43
|
+
* function fetchPools(page: number) {
|
|
44
|
+
* numericRangeValidation(page, 1, 1000, 'page');
|
|
45
|
+
* // Validation passed - proceed with fetch
|
|
46
|
+
* }
|
|
47
|
+
* ```
|
|
48
|
+
*
|
|
49
|
+
* @example With slippage tolerance
|
|
50
|
+
* ```typescript
|
|
51
|
+
* import { numericRangeValidation } from '../utils/validation-patterns';
|
|
52
|
+
*
|
|
53
|
+
* function executeSwap(slippageTolerance: number) {
|
|
54
|
+
* numericRangeValidation(slippageTolerance, 0, 1, 'slippageTolerance');
|
|
55
|
+
* // Validation passed - execute swap
|
|
56
|
+
* }
|
|
57
|
+
* ```
|
|
58
|
+
*
|
|
59
|
+
* @since 6.20.0
|
|
60
|
+
*/
|
|
61
|
+
export declare function numericRangeValidation(value: unknown, min: number, max: number, fieldName: string): void;
|
|
62
|
+
/**
|
|
63
|
+
* Validates string length against maximum constraint
|
|
64
|
+
*
|
|
65
|
+
* Consolidates 8 instances of max length validation found in:
|
|
66
|
+
* - streaming.dto.ts (stream descriptions)
|
|
67
|
+
* - content-flag.dto.ts (flag reasons, descriptions)
|
|
68
|
+
* - comment.dto.ts (comment content)
|
|
69
|
+
* - ban.dto.ts (ban reasons)
|
|
70
|
+
*
|
|
71
|
+
* ## Replaces Pattern
|
|
72
|
+
*
|
|
73
|
+
* ### Before (Duplicate across DTOs):
|
|
74
|
+
* ```typescript
|
|
75
|
+
* if (typeof value !== 'string' || value.length > MAX_LENGTH) {
|
|
76
|
+
* throw new ValidationError(`Description must be at most ${MAX_LENGTH} characters`);
|
|
77
|
+
* }
|
|
78
|
+
* ```
|
|
79
|
+
*
|
|
80
|
+
* ### After (Single call):
|
|
81
|
+
* ```typescript
|
|
82
|
+
* stringMaxLengthValidation(description, 500, 'description');
|
|
83
|
+
* ```
|
|
84
|
+
*
|
|
85
|
+
* @param value The string to validate
|
|
86
|
+
* @param maxLength Maximum allowed length
|
|
87
|
+
* @param fieldName Field name for error messages (e.g., 'description', 'reason')
|
|
88
|
+
* @throws {ValidationError} If value is not a string or exceeds max length
|
|
89
|
+
*
|
|
90
|
+
* @example Basic usage with comment content
|
|
91
|
+
* ```typescript
|
|
92
|
+
* import { stringMaxLengthValidation } from '../utils/validation-patterns';
|
|
93
|
+
*
|
|
94
|
+
* function postComment(content: unknown) {
|
|
95
|
+
* stringMaxLengthValidation(content, 1000, 'content');
|
|
96
|
+
* // Validation passed - post comment
|
|
97
|
+
* }
|
|
98
|
+
* ```
|
|
99
|
+
*
|
|
100
|
+
* @example With ban reason
|
|
101
|
+
* ```typescript
|
|
102
|
+
* import { stringMaxLengthValidation } from '../utils/validation-patterns';
|
|
103
|
+
*
|
|
104
|
+
* function createBan(reason: unknown) {
|
|
105
|
+
* stringMaxLengthValidation(reason, 500, 'reason');
|
|
106
|
+
* // Validation passed - create ban
|
|
107
|
+
* }
|
|
108
|
+
* ```
|
|
109
|
+
*
|
|
110
|
+
* @since 6.20.0
|
|
111
|
+
*/
|
|
112
|
+
export declare function stringMaxLengthValidation(value: unknown, maxLength: number, fieldName: string): void;
|
|
113
|
+
/**
|
|
114
|
+
* Validates array type and non-empty requirement with type assertion
|
|
115
|
+
*
|
|
116
|
+
* Consolidates 6 instances of array validation found in:
|
|
117
|
+
* - token-service.ts (batch token operations)
|
|
118
|
+
* - lock.dto.ts (batch lock entries)
|
|
119
|
+
* - burn.dto.ts (batch burn entries)
|
|
120
|
+
* - transfer.dto.ts (batch transfer entries)
|
|
121
|
+
*
|
|
122
|
+
* ## Replaces Pattern
|
|
123
|
+
*
|
|
124
|
+
* ### Before (Duplicate across DTOs):
|
|
125
|
+
* ```typescript
|
|
126
|
+
* if (!Array.isArray(arr) || arr.length === 0) {
|
|
127
|
+
* throw new ValidationError('Tokens array is required and must not be empty');
|
|
128
|
+
* }
|
|
129
|
+
* ```
|
|
130
|
+
*
|
|
131
|
+
* ### After (Single call with type assertion):
|
|
132
|
+
* ```typescript
|
|
133
|
+
* arrayNonEmptyValidation<Token>(entries, 'tokens');
|
|
134
|
+
* // entries is now typed as Token[] (type narrowed)
|
|
135
|
+
* ```
|
|
136
|
+
*
|
|
137
|
+
* @template T The element type of the array being validated
|
|
138
|
+
* @param arr The value to validate (should be an array)
|
|
139
|
+
* @param fieldName Field name for error messages (e.g., 'tokens', 'entries')
|
|
140
|
+
* @throws {ValidationError} If arr is not an array or is empty
|
|
141
|
+
*
|
|
142
|
+
* @example Basic batch operation validation
|
|
143
|
+
* ```typescript
|
|
144
|
+
* import { arrayNonEmptyValidation } from '../utils/validation-patterns';
|
|
145
|
+
*
|
|
146
|
+
* interface TokenEntry { tokenName: string; amount: string; }
|
|
147
|
+
*
|
|
148
|
+
* function lockTokens(entries: unknown) {
|
|
149
|
+
* arrayNonEmptyValidation<TokenEntry>(entries, 'tokens');
|
|
150
|
+
* // entries is now TokenEntry[] - safe to iterate
|
|
151
|
+
* entries.forEach(e => console.log(e.tokenName));
|
|
152
|
+
* }
|
|
153
|
+
* ```
|
|
154
|
+
*
|
|
155
|
+
* @example With type narrowing for error handling
|
|
156
|
+
* ```typescript
|
|
157
|
+
* import { arrayNonEmptyValidation } from '../utils/validation-patterns';
|
|
158
|
+
*
|
|
159
|
+
* function processEntries(data: unknown) {
|
|
160
|
+
* try {
|
|
161
|
+
* arrayNonEmptyValidation<CustomType>(data, 'entries');
|
|
162
|
+
* // data is now CustomType[]
|
|
163
|
+
* } catch (error) {
|
|
164
|
+
* if (error instanceof ValidationError) {
|
|
165
|
+
* console.log(error.message); // "Entries array is required and must not be empty"
|
|
166
|
+
* }
|
|
167
|
+
* }
|
|
168
|
+
* }
|
|
169
|
+
* ```
|
|
170
|
+
*
|
|
171
|
+
* @since 6.20.0
|
|
172
|
+
*/
|
|
173
|
+
export declare function arrayNonEmptyValidation<T>(arr: unknown, fieldName: string): asserts arr is T[];
|
|
174
|
+
/**
|
|
175
|
+
* Validates integer type, integer check, and positive value constraint
|
|
176
|
+
*
|
|
177
|
+
* Consolidates 4 instances of positive integer validation found in:
|
|
178
|
+
* - comment.dto.ts (parent comment ID)
|
|
179
|
+
* - content-flag.dto.ts (entity ID)
|
|
180
|
+
* - moderator.dto.ts (invite ID)
|
|
181
|
+
* - streaming.dto.ts (asset ID validation)
|
|
182
|
+
*
|
|
183
|
+
* ## Replaces Pattern
|
|
184
|
+
*
|
|
185
|
+
* ### Before (Duplicate across DTOs):
|
|
186
|
+
* ```typescript
|
|
187
|
+
* if (typeof id !== 'number' || !Number.isInteger(id) || id <= 0) {
|
|
188
|
+
* throw new ValidationError('ID must be a positive integer');
|
|
189
|
+
* }
|
|
190
|
+
* ```
|
|
191
|
+
*
|
|
192
|
+
* ### After (Single call):
|
|
193
|
+
* ```typescript
|
|
194
|
+
* positiveIntegerValidation(id, 'id');
|
|
195
|
+
* ```
|
|
196
|
+
*
|
|
197
|
+
* @param value The value to validate
|
|
198
|
+
* @param fieldName Field name for error messages (e.g., 'id', 'count')
|
|
199
|
+
* @throws {ValidationError} If value is not a positive integer
|
|
200
|
+
*
|
|
201
|
+
* @example ID validation
|
|
202
|
+
* ```typescript
|
|
203
|
+
* import { positiveIntegerValidation } from '../utils/validation-patterns';
|
|
204
|
+
*
|
|
205
|
+
* function getComment(commentId: unknown) {
|
|
206
|
+
* positiveIntegerValidation(commentId, 'commentId');
|
|
207
|
+
* // Validation passed - fetch comment
|
|
208
|
+
* }
|
|
209
|
+
* ```
|
|
210
|
+
*
|
|
211
|
+
* @example Count validation
|
|
212
|
+
* ```typescript
|
|
213
|
+
* import { positiveIntegerValidation } from '../utils/validation-patterns';
|
|
214
|
+
*
|
|
215
|
+
* function fetchPaginated(limit: unknown) {
|
|
216
|
+
* positiveIntegerValidation(limit, 'limit');
|
|
217
|
+
* // Validation passed - fetch with limit
|
|
218
|
+
* }
|
|
219
|
+
* ```
|
|
220
|
+
*
|
|
221
|
+
* @since 6.20.0
|
|
222
|
+
*/
|
|
223
|
+
export declare function positiveIntegerValidation(value: unknown, fieldName: string): void;
|
|
224
|
+
/**
|
|
225
|
+
* Validates enum membership checking using Object.values() approach
|
|
226
|
+
*
|
|
227
|
+
* Consolidates 5 instances of enum validation found in:
|
|
228
|
+
* - content-flag.dto.ts (ContentType enum)
|
|
229
|
+
* - ban.dto.ts (BanDuration enum)
|
|
230
|
+
* - moderator.dto.ts (ModeratorRole enum)
|
|
231
|
+
* - api-key.dto.ts (ApiKeyRole enum)
|
|
232
|
+
* - streaming.dto.ts (StreamStatus enum)
|
|
233
|
+
*
|
|
234
|
+
* ## Replaces Pattern
|
|
235
|
+
*
|
|
236
|
+
* ### Before (Duplicate across DTOs):
|
|
237
|
+
* ```typescript
|
|
238
|
+
* const validRoles = Object.values(ROLE_ENUM);
|
|
239
|
+
* if (!validRoles.includes(value)) {
|
|
240
|
+
* throw new ValidationError(`Role must be one of: ${validRoles.join(', ')}`);
|
|
241
|
+
* }
|
|
242
|
+
* ```
|
|
243
|
+
*
|
|
244
|
+
* ### After (Single call):
|
|
245
|
+
* ```typescript
|
|
246
|
+
* enumValidationWithObjectValues(value, ROLE_ENUM, 'role');
|
|
247
|
+
* ```
|
|
248
|
+
*
|
|
249
|
+
* @template T The type of the enum object
|
|
250
|
+
* @param value The value to validate
|
|
251
|
+
* @param enumObj The enum object containing valid values
|
|
252
|
+
* @param fieldName Field name for error messages (e.g., 'role', 'status')
|
|
253
|
+
* @throws {ValidationError} If value is not a member of the enum
|
|
254
|
+
*
|
|
255
|
+
* @example Role validation
|
|
256
|
+
* ```typescript
|
|
257
|
+
* import { enumValidationWithObjectValues } from '../utils/validation-patterns';
|
|
258
|
+
*
|
|
259
|
+
* enum ContentType {
|
|
260
|
+
* CHAT_MESSAGE = 'CHAT_MESSAGE',
|
|
261
|
+
* COMMENT = 'COMMENT',
|
|
262
|
+
* STREAM = 'STREAM'
|
|
263
|
+
* }
|
|
264
|
+
*
|
|
265
|
+
* function flagContent(type: unknown) {
|
|
266
|
+
* enumValidationWithObjectValues(type, ContentType, 'contentType');
|
|
267
|
+
* // Validation passed - type is valid enum member
|
|
268
|
+
* }
|
|
269
|
+
* ```
|
|
270
|
+
*
|
|
271
|
+
* @example Status validation
|
|
272
|
+
* ```typescript
|
|
273
|
+
* import { enumValidationWithObjectValues } from '../utils/validation-patterns';
|
|
274
|
+
*
|
|
275
|
+
* enum StreamStatus {
|
|
276
|
+
* LIVE = 'LIVE',
|
|
277
|
+
* OFFLINE = 'OFFLINE',
|
|
278
|
+
* SCHEDULED = 'SCHEDULED'
|
|
279
|
+
* }
|
|
280
|
+
*
|
|
281
|
+
* function setStreamStatus(status: unknown) {
|
|
282
|
+
* enumValidationWithObjectValues(status, StreamStatus, 'status');
|
|
283
|
+
* // Validation passed - status is valid
|
|
284
|
+
* }
|
|
285
|
+
* ```
|
|
286
|
+
*
|
|
287
|
+
* @since 6.20.0
|
|
288
|
+
*/
|
|
289
|
+
export declare function enumValidationWithObjectValues<T extends Record<string, string | number>>(value: unknown, enumObj: T, fieldName: string): void;
|
|
290
|
+
/**
|
|
291
|
+
* Validates value against constraint min/max properties
|
|
292
|
+
*
|
|
293
|
+
* Consolidates 5 instances of constraint-based range validation found in:
|
|
294
|
+
* - bonding-curve-service.ts (fee portion constraints)
|
|
295
|
+
* - dex-service.ts (slippage constraints)
|
|
296
|
+
* - liquidity-service.ts (price range constraints)
|
|
297
|
+
* - token-service.ts (decimal constraints)
|
|
298
|
+
*
|
|
299
|
+
* ## Replaces Pattern
|
|
300
|
+
*
|
|
301
|
+
* ### Before (Duplicate across services):
|
|
302
|
+
* ```typescript
|
|
303
|
+
* if (constraint.min && value < constraint.min) {
|
|
304
|
+
* throw new ValidationError(`Must be at least ${constraint.min}`);
|
|
305
|
+
* }
|
|
306
|
+
* if (constraint.max && value > constraint.max) {
|
|
307
|
+
* throw new ValidationError(`Must be at most ${constraint.max}`);
|
|
308
|
+
* }
|
|
309
|
+
* ```
|
|
310
|
+
*
|
|
311
|
+
* ### After (Single call):
|
|
312
|
+
* ```typescript
|
|
313
|
+
* constraintLengthRangeValidation(value, BEE_CONSTRAINT, 'feePortion');
|
|
314
|
+
* ```
|
|
315
|
+
*
|
|
316
|
+
* @param value The value to validate (string or number)
|
|
317
|
+
* @param constraint Constraint object with optional min and max properties
|
|
318
|
+
* @param fieldName Field name for error messages (e.g., 'feePortion', 'decimals')
|
|
319
|
+
* @throws {ValidationError} If value violates constraint bounds
|
|
320
|
+
*
|
|
321
|
+
* @example Fee constraint validation
|
|
322
|
+
* ```typescript
|
|
323
|
+
* import { constraintLengthRangeValidation } from '../utils/validation-patterns';
|
|
324
|
+
*
|
|
325
|
+
* interface FeeConstraint {
|
|
326
|
+
* min?: number;
|
|
327
|
+
* max?: number;
|
|
328
|
+
* }
|
|
329
|
+
*
|
|
330
|
+
* const FEE_CONSTRAINT: FeeConstraint = { min: 0.1, max: 0.5 };
|
|
331
|
+
*
|
|
332
|
+
* function setBondingCurveFee(feePortion: unknown) {
|
|
333
|
+
* constraintLengthRangeValidation(feePortion, FEE_CONSTRAINT, 'feePortion');
|
|
334
|
+
* // Validation passed - fee is within constraints
|
|
335
|
+
* }
|
|
336
|
+
* ```
|
|
337
|
+
*
|
|
338
|
+
* @example Slippage constraint validation
|
|
339
|
+
* ```typescript
|
|
340
|
+
* import { constraintLengthRangeValidation } from '../utils/validation-patterns';
|
|
341
|
+
*
|
|
342
|
+
* const SLIPPAGE_CONSTRAINT = { min: 0, max: 10 };
|
|
343
|
+
*
|
|
344
|
+
* function setSlippageTolerance(tolerance: unknown) {
|
|
345
|
+
* constraintLengthRangeValidation(tolerance, SLIPPAGE_CONSTRAINT, 'slippageTolerance');
|
|
346
|
+
* // Validation passed - slippage is within constraints
|
|
347
|
+
* }
|
|
348
|
+
* ```
|
|
349
|
+
*
|
|
350
|
+
* @since 6.20.0
|
|
351
|
+
*/
|
|
352
|
+
export declare function constraintLengthRangeValidation(value: unknown, constraint: {
|
|
353
|
+
min?: number;
|
|
354
|
+
max?: number;
|
|
355
|
+
}, fieldName: string): void;
|
|
356
|
+
/**
|
|
357
|
+
* Validates that minimum value is less than or equal to maximum value
|
|
358
|
+
*
|
|
359
|
+
* Consolidates 3 instances of min/max comparison validation found in:
|
|
360
|
+
* - liquidity-service.ts (tick range validation)
|
|
361
|
+
* - dex-service.ts (price range validation)
|
|
362
|
+
* - bonding-curve-service.ts (fee range validation)
|
|
363
|
+
*
|
|
364
|
+
* ## Replaces Pattern
|
|
365
|
+
*
|
|
366
|
+
* ### Before (Duplicate across services):
|
|
367
|
+
* ```typescript
|
|
368
|
+
* if (minValue > maxValue) {
|
|
369
|
+
* throw new ValidationError('Minimum must be less than or equal to maximum');
|
|
370
|
+
* }
|
|
371
|
+
* ```
|
|
372
|
+
*
|
|
373
|
+
* ### After (Single call):
|
|
374
|
+
* ```typescript
|
|
375
|
+
* minMaxComparisonValidation(minPrice, maxPrice, 'priceRange');
|
|
376
|
+
* ```
|
|
377
|
+
*
|
|
378
|
+
* @param min The minimum value to compare
|
|
379
|
+
* @param max The maximum value to compare
|
|
380
|
+
* @param fieldName Optional field name for error messages (e.g., 'priceRange', 'tickRange')
|
|
381
|
+
* @throws {ValidationError} If min > max
|
|
382
|
+
*
|
|
383
|
+
* @example Tick range validation
|
|
384
|
+
* ```typescript
|
|
385
|
+
* import { minMaxComparisonValidation } from '../utils/validation-patterns';
|
|
386
|
+
*
|
|
387
|
+
* function addLiquidity(minTick: number, maxTick: number) {
|
|
388
|
+
* minMaxComparisonValidation(minTick, maxTick, 'tickRange');
|
|
389
|
+
* // Validation passed - tick range is valid
|
|
390
|
+
* }
|
|
391
|
+
* ```
|
|
392
|
+
*
|
|
393
|
+
* @example Price range validation
|
|
394
|
+
* ```typescript
|
|
395
|
+
* import { minMaxComparisonValidation } from '../utils/validation-patterns';
|
|
396
|
+
*
|
|
397
|
+
* function setPriceRange(minPrice: string, maxPrice: string) {
|
|
398
|
+
* minMaxComparisonValidation(minPrice, maxPrice, 'priceRange');
|
|
399
|
+
* // Validation passed - price range is valid
|
|
400
|
+
* }
|
|
401
|
+
* ```
|
|
402
|
+
*
|
|
403
|
+
* @since 6.20.0
|
|
404
|
+
*/
|
|
405
|
+
export declare function minMaxComparisonValidation(min: number | string, max: number | string, fieldName?: string): void;
|
|
406
|
+
/**
|
|
407
|
+
* Validates date type accepting Date, string, or number with NaN validation
|
|
408
|
+
*
|
|
409
|
+
* Consolidates 4 instances of date type validation found in:
|
|
410
|
+
* - price-history-service.ts (date range validation)
|
|
411
|
+
* - monitoring-service.ts (event filter dates)
|
|
412
|
+
* - cache-warming-service.ts (cache expiration dates)
|
|
413
|
+
* - utility-service.ts (timestamp validation)
|
|
414
|
+
*
|
|
415
|
+
* ## Replaces Pattern
|
|
416
|
+
*
|
|
417
|
+
* ### Before (Duplicate across services):
|
|
418
|
+
* ```typescript
|
|
419
|
+
* if (typeof date !== 'object' && typeof date !== 'string' && typeof date !== 'number') {
|
|
420
|
+
* throw new ValidationError('Date must be a Date, string, or number');
|
|
421
|
+
* }
|
|
422
|
+
* if (typeof date === 'number' && isNaN(date)) {
|
|
423
|
+
* throw new ValidationError('Date timestamp must be a valid number');
|
|
424
|
+
* }
|
|
425
|
+
* ```
|
|
426
|
+
*
|
|
427
|
+
* ### After (Single call with type assertion):
|
|
428
|
+
* ```typescript
|
|
429
|
+
* dateTypeValidation(value, 'startDate');
|
|
430
|
+
* // value is now typed as Date | string | number (not NaN)
|
|
431
|
+
* ```
|
|
432
|
+
*
|
|
433
|
+
* @param value The value to validate
|
|
434
|
+
* @param fieldName Field name for error messages (e.g., 'startDate', 'timestamp')
|
|
435
|
+
* @throws {ValidationError} If value is not a valid date type or is NaN
|
|
436
|
+
*
|
|
437
|
+
* @example Date range validation
|
|
438
|
+
* ```typescript
|
|
439
|
+
* import { dateTypeValidation } from '../utils/validation-patterns';
|
|
440
|
+
*
|
|
441
|
+
* function fetchPriceHistory(from: unknown, to: unknown) {
|
|
442
|
+
* dateTypeValidation(from, 'fromDate');
|
|
443
|
+
* dateTypeValidation(to, 'toDate');
|
|
444
|
+
* // Both are now Date | string | number - safe to use
|
|
445
|
+
* }
|
|
446
|
+
* ```
|
|
447
|
+
*
|
|
448
|
+
* @example Event filter validation
|
|
449
|
+
* ```typescript
|
|
450
|
+
* import { dateTypeValidation } from '../utils/validation-patterns';
|
|
451
|
+
*
|
|
452
|
+
* function filterEvents(startTime: unknown) {
|
|
453
|
+
* dateTypeValidation(startTime, 'startTime');
|
|
454
|
+
* // startTime is now Date | string | number
|
|
455
|
+
* const timestamp = new Date(startTime).getTime();
|
|
456
|
+
* }
|
|
457
|
+
* ```
|
|
458
|
+
*
|
|
459
|
+
* @since 6.20.0
|
|
460
|
+
*/
|
|
461
|
+
export declare function dateTypeValidation(value: unknown, fieldName: string): asserts value is Date | string | number;
|
|
462
|
+
/**
|
|
463
|
+
* Validates string is not empty or whitespace-only with optional allowEmpty flag
|
|
464
|
+
*
|
|
465
|
+
* Consolidates 5 instances of string emptiness validation found in:
|
|
466
|
+
* - transfer.dto.ts (description validation)
|
|
467
|
+
* - content-flag.dto.ts (reason validation)
|
|
468
|
+
* - comment.dto.ts (content validation)
|
|
469
|
+
* - streaming.dto.ts (title validation)
|
|
470
|
+
* - ban.dto.ts (reason validation)
|
|
471
|
+
*
|
|
472
|
+
* ## Replaces Pattern
|
|
473
|
+
*
|
|
474
|
+
* ### Before (Duplicate across DTOs):
|
|
475
|
+
* ```typescript
|
|
476
|
+
* if (typeof value !== 'string' || value.trim().length === 0) {
|
|
477
|
+
* throw new ValidationError('Reason is required and cannot be empty');
|
|
478
|
+
* }
|
|
479
|
+
* ```
|
|
480
|
+
*
|
|
481
|
+
* ### After (Single call):
|
|
482
|
+
* ```typescript
|
|
483
|
+
* stringEmptyLengthValidation(reason, 'reason', false);
|
|
484
|
+
* ```
|
|
485
|
+
*
|
|
486
|
+
* @param value The value to validate
|
|
487
|
+
* @param fieldName Field name for error messages (e.g., 'reason', 'content')
|
|
488
|
+
* @param allowEmpty Whether to allow empty strings (default: false)
|
|
489
|
+
* @throws {ValidationError} If value is not a string or is empty/whitespace (when not allowed)
|
|
490
|
+
*
|
|
491
|
+
* @example Required string validation
|
|
492
|
+
* ```typescript
|
|
493
|
+
* import { stringEmptyLengthValidation } from '../utils/validation-patterns';
|
|
494
|
+
*
|
|
495
|
+
* function createBan(reason: unknown) {
|
|
496
|
+
* stringEmptyLengthValidation(reason, 'reason', false);
|
|
497
|
+
* // Validation passed - reason is non-empty string
|
|
498
|
+
* }
|
|
499
|
+
* ```
|
|
500
|
+
*
|
|
501
|
+
* @example Optional string validation
|
|
502
|
+
* ```typescript
|
|
503
|
+
* import { stringEmptyLengthValidation } from '../utils/validation-patterns';
|
|
504
|
+
*
|
|
505
|
+
* function updateComment(description: unknown) {
|
|
506
|
+
* stringEmptyLengthValidation(description, 'description', true);
|
|
507
|
+
* // Validation passed - description can be empty or non-empty string
|
|
508
|
+
* }
|
|
509
|
+
* ```
|
|
510
|
+
*
|
|
511
|
+
* @since 6.20.0
|
|
512
|
+
*/
|
|
513
|
+
export declare function stringEmptyLengthValidation(value: unknown, fieldName: string, allowEmpty?: boolean): void;
|
|
514
|
+
/**
|
|
515
|
+
* Generic type checking with error factory pattern for flexible error customization
|
|
516
|
+
*
|
|
517
|
+
* Consolidates 4 instances of type checking with custom errors found in:
|
|
518
|
+
* - moderator.dto.ts (complex validation rules)
|
|
519
|
+
* - api-key.dto.ts (role type checking)
|
|
520
|
+
* - streaming.dto.ts (enum type validation)
|
|
521
|
+
* - content-flag.dto.ts (flag type validation)
|
|
522
|
+
*
|
|
523
|
+
* ## Replaces Pattern
|
|
524
|
+
*
|
|
525
|
+
* ### Before (Duplicate across DTOs):
|
|
526
|
+
* ```typescript
|
|
527
|
+
* if (typeof value !== 'string') {
|
|
528
|
+
* throw new ValidationError(`Expected string but got ${typeof value}`);
|
|
529
|
+
* }
|
|
530
|
+
* ```
|
|
531
|
+
*
|
|
532
|
+
* ### After (Single call):
|
|
533
|
+
* ```typescript
|
|
534
|
+
* fieldTypeCheckWithError(value, 'string', 'tokenName');
|
|
535
|
+
* ```
|
|
536
|
+
*
|
|
537
|
+
* @param value The value to check
|
|
538
|
+
* @param expectedType The expected type name (e.g., 'string', 'number', 'object')
|
|
539
|
+
* @param fieldName Field name for error messages (e.g., 'role', 'tokenName')
|
|
540
|
+
* @throws {ValidationError} If value type does not match expected type
|
|
541
|
+
*
|
|
542
|
+
* @example Basic type checking
|
|
543
|
+
* ```typescript
|
|
544
|
+
* import { fieldTypeCheckWithError } from '../utils/validation-patterns';
|
|
545
|
+
*
|
|
546
|
+
* function setRole(role: unknown) {
|
|
547
|
+
* fieldTypeCheckWithError(role, 'string', 'role');
|
|
548
|
+
* // Validation passed - role is a string
|
|
549
|
+
* }
|
|
550
|
+
* ```
|
|
551
|
+
*
|
|
552
|
+
* @example Object type checking
|
|
553
|
+
* ```typescript
|
|
554
|
+
* import { fieldTypeCheckWithError } from '../utils/validation-patterns';
|
|
555
|
+
*
|
|
556
|
+
* function setConfig(config: unknown) {
|
|
557
|
+
* fieldTypeCheckWithError(config, 'object', 'config');
|
|
558
|
+
* // Validation passed - config is an object
|
|
559
|
+
* }
|
|
560
|
+
* ```
|
|
561
|
+
*
|
|
562
|
+
* @since 6.20.0
|
|
563
|
+
*/
|
|
564
|
+
export declare function fieldTypeCheckWithError(value: unknown, expectedType: string, fieldName: string): void;
|
|
565
|
+
/**
|
|
566
|
+
* Validates sort direction enum value (ASC or DESC)
|
|
567
|
+
*
|
|
568
|
+
* Consolidates 7 instances of sort direction validation found in:
|
|
569
|
+
* - GSwapPoolQueryService.ts (pool listing sort)
|
|
570
|
+
* - ChatService.ts (message sorting)
|
|
571
|
+
* - CommentsService.ts (comment thread sorting)
|
|
572
|
+
* - OverseersService.ts (list sorting)
|
|
573
|
+
* - BanService.ts (ban list sorting)
|
|
574
|
+
* - ModeratorInviteService.ts (invite list sorting)
|
|
575
|
+
* - common.ts (type definitions)
|
|
576
|
+
*
|
|
577
|
+
* ## Replaces Pattern
|
|
578
|
+
*
|
|
579
|
+
* ### Before (Duplicate across services):
|
|
580
|
+
* ```typescript
|
|
581
|
+
* if (sortDir !== 'ASC' && sortDir !== 'DESC') {
|
|
582
|
+
* throw new ValidationError(`Invalid sort direction: ${sortDir}`);
|
|
583
|
+
* }
|
|
584
|
+
* ```
|
|
585
|
+
*
|
|
586
|
+
* ### After (Single call):
|
|
587
|
+
* ```typescript
|
|
588
|
+
* validateSortOrderDirection(sortDir, 'sortDir');
|
|
589
|
+
* ```
|
|
590
|
+
*
|
|
591
|
+
* @param value The sort direction value to validate ('ASC' or 'DESC')
|
|
592
|
+
* @param fieldName Field name for error messages (e.g., 'sortDir', 'sortOrder')
|
|
593
|
+
* @throws {ValidationError} If value is not 'ASC' or 'DESC'
|
|
594
|
+
*
|
|
595
|
+
* @example Basic sort direction validation
|
|
596
|
+
* ```typescript
|
|
597
|
+
* import { validateSortOrderDirection } from '../utils/validation-patterns';
|
|
598
|
+
*
|
|
599
|
+
* function listComments(options: { sortDir?: string }) {
|
|
600
|
+
* if (options.sortDir) {
|
|
601
|
+
* validateSortOrderDirection(options.sortDir, 'sortDir');
|
|
602
|
+
* }
|
|
603
|
+
* // Validation passed - sortDir is either 'ASC' or 'DESC'
|
|
604
|
+
* }
|
|
605
|
+
* ```
|
|
606
|
+
*
|
|
607
|
+
* @example With service method
|
|
608
|
+
* ```typescript
|
|
609
|
+
* import { validateSortOrderDirection } from '../utils/validation-patterns';
|
|
610
|
+
*
|
|
611
|
+
* async getMessages(tokenName: string, sortDir: string = 'DESC') {
|
|
612
|
+
* validateSortOrderDirection(sortDir, 'sortDir');
|
|
613
|
+
* // Fetch and return messages sorted in the specified direction
|
|
614
|
+
* }
|
|
615
|
+
* ```
|
|
616
|
+
*
|
|
617
|
+
* @since 6.25.0
|
|
618
|
+
*/
|
|
619
|
+
export declare function validateSortOrderDirection(value: string, fieldName: string): void;
|
|
620
|
+
/**
|
|
621
|
+
* Validates decimal number within range (handles NaN, Infinity, type checking)
|
|
622
|
+
*
|
|
623
|
+
* Consolidates 5 instances of strict decimal range validation found in:
|
|
624
|
+
* - validation-patterns.ts (utility validation)
|
|
625
|
+
* - GSwapLiquidityMutationService.ts (slippage tolerance)
|
|
626
|
+
* - PoolCalculationService.ts (price impact bounds)
|
|
627
|
+
* - constraints.ts (type definitions)
|
|
628
|
+
* - swapHandler.ts (MCP handler validation)
|
|
629
|
+
*
|
|
630
|
+
* ## Replaces Pattern
|
|
631
|
+
*
|
|
632
|
+
* ### Before (Duplicate across services):
|
|
633
|
+
* ```typescript
|
|
634
|
+
* const num = parseFloat(value);
|
|
635
|
+
* if (isNaN(num) || num < min || num > max) {
|
|
636
|
+
* throw new ValidationError(`${fieldName} must be between ${min} and ${max}`);
|
|
637
|
+
* }
|
|
638
|
+
* ```
|
|
639
|
+
*
|
|
640
|
+
* ### After (Single call):
|
|
641
|
+
* ```typescript
|
|
642
|
+
* validateDecimalRangeStrict(value, min, max, 'slippageTolerance');
|
|
643
|
+
* ```
|
|
644
|
+
*
|
|
645
|
+
* @param value The value to validate (string or number)
|
|
646
|
+
* @param min Minimum allowed value (inclusive)
|
|
647
|
+
* @param max Maximum allowed value (inclusive)
|
|
648
|
+
* @param fieldName Field name for error messages (e.g., 'slippageTolerance', 'priceImpact')
|
|
649
|
+
* @throws {ValidationError} If value is not a valid number within range, or if NaN/Infinity detected
|
|
650
|
+
*
|
|
651
|
+
* @example Slippage tolerance validation
|
|
652
|
+
* ```typescript
|
|
653
|
+
* import { validateDecimalRangeStrict } from '../utils/validation-patterns';
|
|
654
|
+
*
|
|
655
|
+
* function swap(slippage: unknown) {
|
|
656
|
+
* validateDecimalRangeStrict(slippage, 0, 1, 'slippageTolerance');
|
|
657
|
+
* // Validation passed - slippage is a valid decimal between 0 and 1
|
|
658
|
+
* }
|
|
659
|
+
* ```
|
|
660
|
+
*
|
|
661
|
+
* @example Price impact validation
|
|
662
|
+
* ```typescript
|
|
663
|
+
* import { validateDecimalRangeStrict } from '../utils/validation-patterns';
|
|
664
|
+
*
|
|
665
|
+
* function calculateImpact(impactPercent: unknown) {
|
|
666
|
+
* validateDecimalRangeStrict(impactPercent, 0, 100, 'priceImpact');
|
|
667
|
+
* // Validation passed - impact is valid percentage between 0 and 100
|
|
668
|
+
* }
|
|
669
|
+
* ```
|
|
670
|
+
*
|
|
671
|
+
* @since 6.25.0
|
|
672
|
+
*/
|
|
673
|
+
export declare function validateDecimalRangeStrict(value: string | number, min: number, max: number, fieldName: string): void;
|
|
674
|
+
/**
|
|
675
|
+
* Validates reverse bonding curve fee portion bounds.
|
|
676
|
+
*
|
|
677
|
+
* Ensures that:
|
|
678
|
+
* - minFee >= 0.1 (minimum fee portion)
|
|
679
|
+
* - maxFee <= 0.5 (maximum fee portion)
|
|
680
|
+
* - minFee <= maxFee (logical ordering)
|
|
681
|
+
*
|
|
682
|
+
* @param minFee - Minimum fee portion (0.1 to 0.5)
|
|
683
|
+
* @param maxFee - Maximum fee portion (0.1 to 0.5)
|
|
684
|
+
* @param fieldName - Field name for error messages
|
|
685
|
+
* @throws {ValidationError} If constraints are violated
|
|
686
|
+
*
|
|
687
|
+
* @example
|
|
688
|
+
* // Valid: min=0.1, max=0.5
|
|
689
|
+
* validateFeePortionConstraints('0.1', '0.5', 'reverseBondingCurve');
|
|
690
|
+
*
|
|
691
|
+
* @example
|
|
692
|
+
* // Invalid: max > 0.5
|
|
693
|
+
* validateFeePortionConstraints(0.1, 0.6, 'feeConfig'); // throws
|
|
694
|
+
*
|
|
695
|
+
* @example
|
|
696
|
+
* // Invalid: min < 0.1
|
|
697
|
+
* validateFeePortionConstraints(0.05, 0.5, 'feeConfig'); // throws
|
|
698
|
+
*
|
|
699
|
+
* @example
|
|
700
|
+
* // Invalid: min > max
|
|
701
|
+
* validateFeePortionConstraints(0.4, 0.2, 'feeConfig'); // throws
|
|
702
|
+
*/
|
|
703
|
+
export declare function validateFeePortionConstraints(minFee: string | number, maxFee: string | number, fieldName: string): void;
|
|
704
|
+
/**
|
|
705
|
+
* Validates that min <= max constraint is satisfied.
|
|
706
|
+
*
|
|
707
|
+
* Ensures that a minimum value does not exceed the maximum value.
|
|
708
|
+
* Supports both string and numeric inputs for flexibility.
|
|
709
|
+
*
|
|
710
|
+
* @param min - Minimum value (can be number or string)
|
|
711
|
+
* @param max - Maximum value (can be number or string)
|
|
712
|
+
* @param minLabel - Label for minimum value (e.g., 'minPrice') for error messages
|
|
713
|
+
* @param maxLabel - Label for maximum value (e.g., 'maxPrice') for error messages
|
|
714
|
+
* @throws {ValidationError} If min > max
|
|
715
|
+
*
|
|
716
|
+
* @example
|
|
717
|
+
* // Valid: min < max
|
|
718
|
+
* validateMinMaxRelationship(0.5, 1.0, 'minPrice', 'maxPrice');
|
|
719
|
+
*
|
|
720
|
+
* @example
|
|
721
|
+
* // Valid: min = max
|
|
722
|
+
* validateMinMaxRelationship(100, 100, 'minLiquidity', 'maxLiquidity');
|
|
723
|
+
*
|
|
724
|
+
* @example
|
|
725
|
+
* // Invalid: min > max
|
|
726
|
+
* validateMinMaxRelationship(10, 5, 'startTick', 'endTick'); // throws
|
|
727
|
+
*/
|
|
728
|
+
export declare function validateMinMaxRelationship(min: number | string, max: number | string, minLabel: string, maxLabel: string): void;
|
|
729
|
+
/**
|
|
730
|
+
* Validate that a value is included in an allowed set of enum values.
|
|
731
|
+
*
|
|
732
|
+
* @param value - The value to validate (string)
|
|
733
|
+
* @param allowedValues - Array of allowed enum values
|
|
734
|
+
* @param fieldName - The field name for error messages
|
|
735
|
+
* @throws ValidationError if value is not in allowedValues
|
|
736
|
+
*
|
|
737
|
+
* @example
|
|
738
|
+
* validateConstrainedEnumVariant(
|
|
739
|
+
* role,
|
|
740
|
+
* [MODERATOR_ROLE.MODERATOR, MODERATOR_ROLE.TECHNICAL_PRODUCER],
|
|
741
|
+
* 'moderatorRole'
|
|
742
|
+
* );
|
|
743
|
+
*/
|
|
744
|
+
export declare function validateConstrainedEnumVariant<T extends Record<string, string> = Record<string, string>>(value: string, allowedValues: T[], fieldName: string): void;
|
|
745
|
+
//# sourceMappingURL=validation-patterns.d.ts.map
|