@gala-chain/launchpad-sdk 5.0.3 → 5.0.4-beta.1
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
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"UserService.d.ts","sourceRoot":"","sources":["../../../src/services/UserService.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"UserService.d.ts","sourceRoot":"","sources":["../../../src/services/UserService.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAa3C,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAI5C,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAC;AAC/C,OAAO,EACL,mBAAmB,EACnB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;;;;;;;OAgBG;YACW,iBAAiB;IAqD/B;;;;OAIG;IACH,OAAO,CAAC,2BAA2B;IAsCnC;;;;OAIG;IACH,OAAO,CAAC,yBAAyB;IAgBjC;;;;OAIG;IACH,OAAO,CAAC,iCAAiC;CAO1C"}
|
|
@@ -94,7 +94,7 @@ export declare class WebSocketService extends LoggerBase {
|
|
|
94
94
|
private config;
|
|
95
95
|
private listeners;
|
|
96
96
|
private timeouts;
|
|
97
|
-
private
|
|
97
|
+
private reconnectionManager;
|
|
98
98
|
private debug;
|
|
99
99
|
private isSocketIOAvailable;
|
|
100
100
|
private hasOnAnyListener;
|
|
@@ -109,12 +109,12 @@ export declare class WebSocketService extends LoggerBase {
|
|
|
109
109
|
* 4. Event is lost forever, SDK hangs waiting for confirmation
|
|
110
110
|
*
|
|
111
111
|
* **The Solution:**
|
|
112
|
-
* Use
|
|
112
|
+
* Use SimpleCache with 30s TTL to auto-clean orphaned events.
|
|
113
|
+
* Buffers ALL bundler events via catch-all listener, regardless of
|
|
113
114
|
* when the specific transactionId listener is registered. This ensures
|
|
114
115
|
* no events are ever lost, even if they arrive milliseconds early.
|
|
115
116
|
*/
|
|
116
117
|
private eventBuffer;
|
|
117
|
-
private eventBufferTimeouts;
|
|
118
118
|
private readonly MAX_BUFFER_SIZE;
|
|
119
119
|
constructor(config: WebSocketConfig, debug?: boolean);
|
|
120
120
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"WebSocketService.d.ts","sourceRoot":"","sources":["../../../src/services/WebSocketService.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAM,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAC9C,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"WebSocketService.d.ts","sourceRoot":"","sources":["../../../src/services/WebSocketService.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAM,MAAM,EAAE,M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jC;;OAEG;IACG,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;IAgH9B;;;;;;;OAOG;IACG,kBAAkB,CACtB,aAAa,EAAE,MAAM,EACrB,QAAQ,EAAE,CAAC,MAAM,EAAE,iBAAiB,KAAK,IAAI,GAC5C,OAAO,CAAC,IAAI,CAAC;IAsFhB;;;;;;;;OAQG;IACH,OAAO,CAAC,uBAAuB;IA2F/B;;OAEG;IACG,kBAAkB,CAAC,aAAa,EAAE,MAAM,GAAG,OAAO,CAAC,iBAAiB,CAAC;IAY3E;;OAEG;IACH,OAAO,CAAC,eAAe;IAKvB;;OAEG;YACW,eAAe;IAmB7B;;OAEG;IACH,UAAU,IAAI,IAAI;IAiClB;;OAEG;IACH,WAAW,IAAI,OAAO;IAItB;;;;;;;;;;;;OAYG;IACH,SAAS,IAAI,MAAM,GAAG,IAAI;CAG3B"}
|
|
@@ -15,6 +15,7 @@ import type { Wallet } from 'ethers';
|
|
|
15
15
|
import type { WrappableTokenService } from './WrappableTokenService.js';
|
|
16
16
|
import type { GalaConnectClient } from '../bridge/GalaConnectClient.js';
|
|
17
17
|
import { Logger } from '../utils/Logger.js';
|
|
18
|
+
import { LoggerBase } from './BaseService.js';
|
|
18
19
|
import type { TokenId } from '../types/common.js';
|
|
19
20
|
import type { WrapTokenOptions, UnwrapTokenOptions, WrapUnwrapResult, WrapUnwrapFeeEstimate, WrapUnwrapStatusResult } from '../types/wrappable-token.dto.js';
|
|
20
21
|
/**
|
|
@@ -53,12 +54,11 @@ export interface WrapServiceConfig {
|
|
|
53
54
|
* });
|
|
54
55
|
* ```
|
|
55
56
|
*/
|
|
56
|
-
export declare class WrapService {
|
|
57
|
+
export declare class WrapService extends LoggerBase {
|
|
57
58
|
private readonly galaConnectClient;
|
|
58
59
|
private readonly wrappableTokenService;
|
|
59
60
|
private readonly wallet;
|
|
60
61
|
private readonly walletAddress;
|
|
61
|
-
private readonly logger;
|
|
62
62
|
constructor(config: WrapServiceConfig);
|
|
63
63
|
/**
|
|
64
64
|
* Wrap a token to its asset-channel counterpart
|
|
@@ -108,6 +108,7 @@ export declare class WrapService {
|
|
|
108
108
|
* @param tokenId - Token to wrap
|
|
109
109
|
* @param amount - Amount to wrap
|
|
110
110
|
* @returns Promise<WrapUnwrapFeeEstimate> - Fee estimate
|
|
111
|
+
* @throws ValidationError if tokenId or amount is required but not provided
|
|
111
112
|
*/
|
|
112
113
|
estimateWrapFee(tokenId: TokenId, _amount: string): Promise<WrapUnwrapFeeEstimate>;
|
|
113
114
|
/**
|
|
@@ -116,15 +117,18 @@ export declare class WrapService {
|
|
|
116
117
|
* @param tokenId - Token to unwrap
|
|
117
118
|
* @param amount - Amount to unwrap
|
|
118
119
|
* @returns Promise<WrapUnwrapFeeEstimate> - Fee estimate
|
|
120
|
+
* @throws ValidationError if tokenId or amount is required but not provided
|
|
119
121
|
*/
|
|
120
122
|
estimateUnwrapFee(tokenId: TokenId, _amount: string): Promise<WrapUnwrapFeeEstimate>;
|
|
121
123
|
/**
|
|
122
124
|
* Get status of a wrap/unwrap transaction
|
|
123
125
|
*
|
|
124
|
-
*
|
|
126
|
+
* Cross-channel wrapping completes immediately (synchronous on-chain).
|
|
127
|
+
* This method returns the completed status for the given transaction ID.
|
|
125
128
|
*
|
|
126
129
|
* @param transactionId - Transaction ID to check
|
|
127
|
-
* @returns Promise<WrapUnwrapStatusResult> - Current status
|
|
130
|
+
* @returns Promise<WrapUnwrapStatusResult> - Current status (always completed for wrap/unwrap)
|
|
131
|
+
* @throws ValidationError if transactionId is required but not provided
|
|
128
132
|
*/
|
|
129
133
|
getWrapStatus(transactionId: string): Promise<WrapUnwrapStatusResult>;
|
|
130
134
|
/**
|
|
@@ -139,6 +143,15 @@ export declare class WrapService {
|
|
|
139
143
|
* @see docs/api-calls/swapBridgeOut.txt for working payload example
|
|
140
144
|
*/
|
|
141
145
|
private executeChannelBridge;
|
|
146
|
+
/**
|
|
147
|
+
* Execute wrap bridge request with comprehensive error handling
|
|
148
|
+
*
|
|
149
|
+
* Uses direct try-catch (not withErrorHandling wrapper) because this method
|
|
150
|
+
* returns structured error responses (WrapUnwrapResult with success: false)
|
|
151
|
+
* rather than throwing. This is appropriate for a private helper method that
|
|
152
|
+
* normalizes errors into the return type.
|
|
153
|
+
*/
|
|
154
|
+
private executeWrapBridgeRequest;
|
|
142
155
|
/**
|
|
143
156
|
* Determine channel routing for wrap/unwrap operation
|
|
144
157
|
*
|
|
@@ -152,7 +165,7 @@ export declare class WrapService {
|
|
|
152
165
|
*/
|
|
153
166
|
private requireWallet;
|
|
154
167
|
/**
|
|
155
|
-
* Format tokenId for error messages
|
|
168
|
+
* Format tokenId for error messages using centralized stringification
|
|
156
169
|
*/
|
|
157
170
|
private formatTokenId;
|
|
158
171
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"WrapService.d.ts","sourceRoot":"","sources":["../../../src/services/WrapService.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAIH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AACrC,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAC;AACxE,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,gCAAgC,CAAC;AACxE,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAC5C,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,KAAK,EACV,gBAAgB,EAChB,kBAAkB,EAClB,gBAAgB,EAChB,qBAAqB,EACrB,sBAAsB,EAEvB,MAAM,iCAAiC,CAAC;
|
|
1
|
+
{"version":3,"file":"WrapService.d.ts","sourceRoot":"","sources":["../../../src/services/WrapService.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAIH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AACrC,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAC;AACxE,O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CAAC;IAqCjC;;;;;;;OAOG;IACG,iBAAiB,CACrB,OAAO,EAAE,OAAO,EAChB,OAAO,EAAE,MAAM,GACd,OAAO,CAAC,qBAAqB,CAAC;IAqCjC;;;;;;;;;OASG;IACG,aAAa,CAAC,aAAa,EAAE,MAAM,GAAG,OAAO,CAAC,sBAAsB,CAAC;IAsB3E;;;;;;;;;;OAUG;YACW,oBAAoB;IA6ElC;;;;;;;OAOG;YACW,wBAAwB;IA8JtC;;;;;;OAMG;IACH,OAAO,CAAC,uBAAuB;IAwB/B;;OAEG;IACH,OAAO,CAAC,aAAa;IAUrB;;OAEG;IACH,OAAO,CAAC,aAAa;CAMtB"}
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
*
|
|
4
4
|
* Permanent in-memory cache for wrappable tokens fetched from DEX API.
|
|
5
5
|
* Wrappable tokens are GalaChain-internal token pairs that can be
|
|
6
|
-
* wrapped/unwrapped into each other (e.g., MUSIC
|
|
6
|
+
* wrapped/unwrapped into each other (e.g., MUSIC <-> GMUSIC).
|
|
7
7
|
*
|
|
8
8
|
* ## Cache Architecture
|
|
9
9
|
* - **Primary Index**: Map<tokenId, token> - O(1) by stringifiedTokenClassKey
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
* @since 4.0.18
|
|
20
20
|
*/
|
|
21
21
|
import type { WrappableToken, WrappableTokenCacheStats } from '../types/wrappable-token.dto.js';
|
|
22
|
-
import {
|
|
22
|
+
import { BatchedCacheService } from './BatchedCacheService.js';
|
|
23
23
|
/**
|
|
24
24
|
* Wrappable Token Cache
|
|
25
25
|
*
|
|
@@ -31,7 +31,7 @@ import { LoggerBase } from './BaseService.js';
|
|
|
31
31
|
* const cache = new WrappableTokenCache();
|
|
32
32
|
*
|
|
33
33
|
* // Cache all tokens
|
|
34
|
-
* cache.
|
|
34
|
+
* cache.setAll(wrappableTokens);
|
|
35
35
|
*
|
|
36
36
|
* // Check if cached
|
|
37
37
|
* if (cache.has()) {
|
|
@@ -42,19 +42,15 @@ import { LoggerBase } from './BaseService.js';
|
|
|
42
42
|
* const music = cache.getByTokenId('$MUSIC|Unit|none|none');
|
|
43
43
|
* ```
|
|
44
44
|
*/
|
|
45
|
-
export declare class WrappableTokenCache extends
|
|
46
|
-
/** Primary index: tokenId (stringifiedTokenClassKey) → token */
|
|
47
|
-
private readonly cache;
|
|
48
|
-
/** Timestamp when cache was last populated */
|
|
49
|
-
private lastFetchedAt;
|
|
45
|
+
export declare class WrappableTokenCache extends BatchedCacheService<WrappableToken, WrappableTokenCacheStats> {
|
|
50
46
|
constructor(debugMode?: boolean);
|
|
51
47
|
/**
|
|
52
|
-
*
|
|
48
|
+
* Extract the cache key from a wrappable token
|
|
53
49
|
*
|
|
54
|
-
* @param
|
|
55
|
-
* @returns
|
|
50
|
+
* @param token - Wrappable token
|
|
51
|
+
* @returns The stringifiedTokenClassKey as the key
|
|
56
52
|
*/
|
|
57
|
-
|
|
53
|
+
protected extractKey(token: WrappableToken): string;
|
|
58
54
|
/**
|
|
59
55
|
* Check if cache is populated
|
|
60
56
|
*
|
|
@@ -74,36 +70,12 @@ export declare class WrappableTokenCache extends LoggerBase {
|
|
|
74
70
|
* @returns Wrappable token or undefined if not found
|
|
75
71
|
*/
|
|
76
72
|
getByTokenId(tokenId: string): WrappableToken | undefined;
|
|
77
|
-
/**
|
|
78
|
-
* Set all tokens (replaces existing cache)
|
|
79
|
-
*
|
|
80
|
-
* @param tokens - Array of wrappable tokens
|
|
81
|
-
*/
|
|
82
|
-
set(tokens: WrappableToken[]): void;
|
|
83
|
-
/**
|
|
84
|
-
* Add tokens to cache (merges with existing)
|
|
85
|
-
*
|
|
86
|
-
* Used for pagination - adds new tokens without replacing existing.
|
|
87
|
-
*
|
|
88
|
-
* @param tokens - Array of wrappable tokens to add
|
|
89
|
-
*/
|
|
90
|
-
merge(tokens: WrappableToken[]): void;
|
|
91
|
-
/**
|
|
92
|
-
* Get fetch timestamp
|
|
93
|
-
*
|
|
94
|
-
* @returns Timestamp when cache was last updated, or null if never fetched
|
|
95
|
-
*/
|
|
96
|
-
getFetchTimestamp(): number | null;
|
|
97
73
|
/**
|
|
98
74
|
* Get cache statistics
|
|
99
75
|
*
|
|
100
76
|
* @returns Cache statistics including token count and timestamp
|
|
101
77
|
*/
|
|
102
78
|
getStats(): WrappableTokenCacheStats;
|
|
103
|
-
/**
|
|
104
|
-
* Clear cache
|
|
105
|
-
*/
|
|
106
|
-
clear(): void;
|
|
107
79
|
/**
|
|
108
80
|
* Get number of cached tokens
|
|
109
81
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"WrappableTokenCache.d.ts","sourceRoot":"","sources":["../../../src/services/WrappableTokenCache.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAE,wBAAwB,EAAE,MAAM,iCAAiC,CAAC;AAChG,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"WrappableTokenCache.d.ts","sourceRoot":"","sources":["../../../src/services/WrappableTokenCache.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAE,wBAAwB,EAAE,MAAM,iCAAiC,CAAC;AAChG,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAE/D;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,qBAAa,mBAAoB,SAAQ,mBAAmB,CAAC,cAAc,EAAE,wBAAwB,CAAC;gBACxF,SAAS,GAAE,OAAe;IAItC;;;;;OAKG;IACH,SAAS,CAAC,UAAU,CAAC,KAAK,EAAE,cAAc,GAAG,MAAM;IAInD;;;;OAIG;IACH,GAAG,IAAI,OAAO;IAId;;;;OAIG;IACH,MAAM,IAAI,cAAc,EAAE;IAI1B;;;;;OAKG;IACI,YAAY,CAAC,OAAO,EAAE,MAAM,GAAG,cAAc,GAAG,SAAS;IAIhE;;;;OAIG;IACI,QAAQ,IAAI,wBAAwB;IAQ3C;;;;OAIG;IACH,IAAI,IAAI,MAAM;IAId;;;;;OAKG;IACH,gBAAgB,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO;IAI1C;;;;;OAKG;IACH,kBAAkB,CAAC,OAAO,EAAE,MAAM,GAAG,cAAc,GAAG,SAAS;CAMhE"}
|
|
@@ -18,9 +18,10 @@
|
|
|
18
18
|
* @category Services
|
|
19
19
|
* @since 4.0.18
|
|
20
20
|
*/
|
|
21
|
-
import { HttpClient } from '../utils/http.js';
|
|
21
|
+
import type { HttpClient } from '../utils/http.js';
|
|
22
|
+
import { AbstractTokenFetchService } from './AbstractTokenFetchService.js';
|
|
22
23
|
import type { TokenId } from '../types/common.js';
|
|
23
|
-
import type { WrappableToken, FetchWrappableTokensOptions, FetchWrappableTokensResult, IsTokenWrappableResult, WrappableTokenCacheStats } from '../types/wrappable-token.dto.js';
|
|
24
|
+
import type { WrappableToken, WrappableTokenApiResponse, FetchWrappableTokensOptions, FetchWrappableTokensResult, IsTokenWrappableResult, WrappableTokenCacheStats } from '../types/wrappable-token.dto.js';
|
|
24
25
|
/**
|
|
25
26
|
* WrappableTokenService
|
|
26
27
|
*
|
|
@@ -48,11 +49,23 @@ import type { WrappableToken, FetchWrappableTokensOptions, FetchWrappableTokensR
|
|
|
48
49
|
* console.log(`MUSIC counterpart: ${counterpart?.symbol}`); // GMUSIC
|
|
49
50
|
* ```
|
|
50
51
|
*/
|
|
51
|
-
export declare class WrappableTokenService {
|
|
52
|
-
private readonly dexApiHttp;
|
|
53
|
-
private readonly logger;
|
|
52
|
+
export declare class WrappableTokenService extends AbstractTokenFetchService<WrappableTokenApiResponse, WrappableToken> {
|
|
54
53
|
private readonly cache;
|
|
55
54
|
constructor(dexApiHttp: HttpClient, debugMode?: boolean);
|
|
55
|
+
/**
|
|
56
|
+
* Build API request parameters for wrappable tokens
|
|
57
|
+
*
|
|
58
|
+
* @param _context - Unused context parameter (required by base class)
|
|
59
|
+
* @returns Query parameters with wrappable filter
|
|
60
|
+
*/
|
|
61
|
+
protected buildApiParams(_context?: Record<string, unknown>): Record<string, string | number | boolean>;
|
|
62
|
+
/**
|
|
63
|
+
* Transform API response tokens to SDK format
|
|
64
|
+
*
|
|
65
|
+
* @param apiTokens - Raw API response tokens
|
|
66
|
+
* @returns Array of transformed wrappable tokens
|
|
67
|
+
*/
|
|
68
|
+
protected transformApiResponse(apiTokens: WrappableTokenApiResponse[]): WrappableToken[];
|
|
56
69
|
/**
|
|
57
70
|
* Fetch wrappable tokens with pagination (metadata only, cached)
|
|
58
71
|
*
|
|
@@ -113,12 +126,5 @@ export declare class WrappableTokenService {
|
|
|
113
126
|
* Clear cache
|
|
114
127
|
*/
|
|
115
128
|
clearCache(): void;
|
|
116
|
-
/**
|
|
117
|
-
* Transform API response tokens to SDK format
|
|
118
|
-
*
|
|
119
|
-
* @param apiTokens - Raw API response tokens
|
|
120
|
-
* @returns Array of transformed wrappable tokens
|
|
121
|
-
*/
|
|
122
|
-
private transformTokens;
|
|
123
129
|
}
|
|
124
130
|
//# sourceMappingURL=WrappableTokenService.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"WrappableTokenService.d.ts","sourceRoot":"","sources":["../../../src/services/WrappableTokenService.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"WrappableTokenService.d.ts","sourceRoot":"","sources":["../../../src/services/WrappableTokenService.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAInD,OAAO,EAAE,yBAAyB,EAAE,MAAM,gCAAgC,CAAC;AAG3E,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,KAAK,EACV,cAAc,EACd,yBAAyB,EACzB,2BAA2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-fetch-store patterns.
|
|
6
|
+
*
|
|
7
|
+
* @category Services
|
|
8
|
+
* @since 6.4.0
|
|
9
|
+
*/
|
|
10
|
+
import type { Logger } from '../../utils/Logger';
|
|
11
|
+
/**
|
|
12
|
+
* Options for withCache wrapper
|
|
13
|
+
*/
|
|
14
|
+
export interface WithCacheOptions<K = string> {
|
|
15
|
+
/** Logger instance for debug output */
|
|
16
|
+
logger?: Logger;
|
|
17
|
+
/** Time-to-live in milliseconds (optional, for TTL-based caches) */
|
|
18
|
+
ttlMs?: number;
|
|
19
|
+
/** Key generator function (defaults to identity for string keys) */
|
|
20
|
+
keyGenerator?: (input: K) => string;
|
|
21
|
+
/** Whether to cache null/undefined results (default: false) */
|
|
22
|
+
cacheNullish?: boolean;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Simple in-memory cache with optional TTL support
|
|
26
|
+
*
|
|
27
|
+
* Used internally by cache helpers and can be used directly for
|
|
28
|
+
* custom caching scenarios.
|
|
29
|
+
*
|
|
30
|
+
* @typeParam V - Value type stored in cache
|
|
31
|
+
*
|
|
32
|
+
* @example
|
|
33
|
+
* ```typescript
|
|
34
|
+
* const cache = new SimpleCache<UserData>(60000); // 1 minute TTL
|
|
35
|
+
* cache.set('user:123', userData);
|
|
36
|
+
* const cached = cache.get('user:123'); // Returns userData or undefined if expired
|
|
37
|
+
* ```
|
|
38
|
+
*
|
|
39
|
+
* @since 6.4.0
|
|
40
|
+
*/
|
|
41
|
+
export declare class SimpleCache<V> {
|
|
42
|
+
private defaultTtlMs;
|
|
43
|
+
private cache;
|
|
44
|
+
/**
|
|
45
|
+
* Create a new SimpleCache
|
|
46
|
+
*
|
|
47
|
+
* @param defaultTtlMs - Default TTL in milliseconds (0 = no expiration)
|
|
48
|
+
*/
|
|
49
|
+
constructor(defaultTtlMs?: number);
|
|
50
|
+
/**
|
|
51
|
+
* Get a value from cache
|
|
52
|
+
*
|
|
53
|
+
* @param key - Cache key
|
|
54
|
+
* @returns Cached value or undefined if not found/expired
|
|
55
|
+
*/
|
|
56
|
+
get(key: string): V | undefined;
|
|
57
|
+
/**
|
|
58
|
+
* Set a value in cache
|
|
59
|
+
*
|
|
60
|
+
* @param key - Cache key
|
|
61
|
+
* @param value - Value to cache
|
|
62
|
+
* @param ttlMs - Optional TTL override (uses default if not specified)
|
|
63
|
+
*/
|
|
64
|
+
set(key: string, value: V, ttlMs?: number): void;
|
|
65
|
+
/**
|
|
66
|
+
* Check if a key exists and is not expired
|
|
67
|
+
*
|
|
68
|
+
* @param key - Cache key
|
|
69
|
+
* @returns True if key exists and is not expired
|
|
70
|
+
*/
|
|
71
|
+
has(key: string): boolean;
|
|
72
|
+
/**
|
|
73
|
+
* Delete a key from cache
|
|
74
|
+
*
|
|
75
|
+
* @param key - Cache key
|
|
76
|
+
*/
|
|
77
|
+
delete(key: string): void;
|
|
78
|
+
/**
|
|
79
|
+
* Clear all cached entries
|
|
80
|
+
*/
|
|
81
|
+
clear(): void;
|
|
82
|
+
/**
|
|
83
|
+
* Get cache size
|
|
84
|
+
*/
|
|
85
|
+
get size(): number;
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Wraps an async fetch operation with caching
|
|
89
|
+
*
|
|
90
|
+
* Handles the cache-check-fetch-store pattern in a single utility call.
|
|
91
|
+
*
|
|
92
|
+
* @typeParam V - The expected value type
|
|
93
|
+
* @param key - Cache key (string)
|
|
94
|
+
* @param fetcher - Async function that fetches the data if not cached
|
|
95
|
+
* @param cache - Cache instance (Map-like interface with get/set)
|
|
96
|
+
* @param options - Optional configuration
|
|
97
|
+
* @returns Promise resolving to cached or freshly fetched data
|
|
98
|
+
*
|
|
99
|
+
* @example Basic usage with Map
|
|
100
|
+
* ```typescript
|
|
101
|
+
* const cache = new Map<string, UserData>();
|
|
102
|
+
* const user = await withCache(
|
|
103
|
+
* `user:${userId}`,
|
|
104
|
+
* () => fetchUser(userId),
|
|
105
|
+
* cache
|
|
106
|
+
* );
|
|
107
|
+
* ```
|
|
108
|
+
*
|
|
109
|
+
* @example With TTL-based cache
|
|
110
|
+
* ```typescript
|
|
111
|
+
* const cache = new SimpleCache<PoolData>(60000); // 1 minute TTL
|
|
112
|
+
* const pool = await withCache(
|
|
113
|
+
* `pool:${tokenName}`,
|
|
114
|
+
* () => fetchPool(tokenName),
|
|
115
|
+
* cache,
|
|
116
|
+
* { logger: this.logger }
|
|
117
|
+
* );
|
|
118
|
+
* ```
|
|
119
|
+
*
|
|
120
|
+
* @example With key generator
|
|
121
|
+
* ```typescript
|
|
122
|
+
* const user = await withCache(
|
|
123
|
+
* { userId, includeProfile: true },
|
|
124
|
+
* () => fetchUserWithProfile(userId),
|
|
125
|
+
* cache,
|
|
126
|
+
* { keyGenerator: (opts) => `user:${opts.userId}:${opts.includeProfile}` }
|
|
127
|
+
* );
|
|
128
|
+
* ```
|
|
129
|
+
*
|
|
130
|
+
* @since 6.4.0
|
|
131
|
+
*/
|
|
132
|
+
export declare function withCache<V, K = string>(key: K, fetcher: () => Promise<V>, cache: {
|
|
133
|
+
get: (key: string) => V | undefined;
|
|
134
|
+
set: (key: string, value: V) => void;
|
|
135
|
+
}, options?: WithCacheOptions<K>): Promise<V>;
|
|
136
|
+
/**
|
|
137
|
+
* Creates a memoized version of an async function with caching
|
|
138
|
+
*
|
|
139
|
+
* Useful for creating cached service methods without manual cache management.
|
|
140
|
+
*
|
|
141
|
+
* @typeParam A - Argument type (used for cache key generation)
|
|
142
|
+
* @typeParam R - Return type
|
|
143
|
+
* @param fn - Function to memoize
|
|
144
|
+
* @param keyFn - Function to generate cache key from arguments
|
|
145
|
+
* @param ttlMs - Time-to-live in milliseconds (0 = no expiration)
|
|
146
|
+
* @returns Memoized function
|
|
147
|
+
*
|
|
148
|
+
* @example
|
|
149
|
+
* ```typescript
|
|
150
|
+
* class UserService {
|
|
151
|
+
* // Create memoized fetcher with 5 minute TTL
|
|
152
|
+
* private fetchUserCached = memoizeAsync(
|
|
153
|
+
* (userId: string) => this.fetchUserFromApi(userId),
|
|
154
|
+
* (userId) => `user:${userId}`,
|
|
155
|
+
* 300000 // 5 minutes
|
|
156
|
+
* );
|
|
157
|
+
*
|
|
158
|
+
* async getUser(userId: string) {
|
|
159
|
+
* return this.fetchUserCached(userId);
|
|
160
|
+
* }
|
|
161
|
+
* }
|
|
162
|
+
* ```
|
|
163
|
+
*
|
|
164
|
+
* @since 6.4.0
|
|
165
|
+
*/
|
|
166
|
+
export declare function memoizeAsync<A, R>(fn: (arg: A) => Promise<R>, keyFn: (arg: A) => string, ttlMs?: number): (arg: A) => Promise<R>;
|
|
167
|
+
/**
|
|
168
|
+
* Creates a cache key from multiple parts
|
|
169
|
+
*
|
|
170
|
+
* Utility for building consistent cache keys across services.
|
|
171
|
+
*
|
|
172
|
+
* @param parts - Key parts to join
|
|
173
|
+
* @param separator - Separator character (default: ':')
|
|
174
|
+
* @returns Joined cache key string
|
|
175
|
+
*
|
|
176
|
+
* @example
|
|
177
|
+
* ```typescript
|
|
178
|
+
* const key = buildCacheKey('user', userId, 'profile');
|
|
179
|
+
* // Result: 'user:abc123:profile'
|
|
180
|
+
*
|
|
181
|
+
* const key = buildCacheKey('pool', tokenName, 'stats', { separator: '/' });
|
|
182
|
+
* // Result: 'pool/mytoken/stats'
|
|
183
|
+
* ```
|
|
184
|
+
*
|
|
185
|
+
* @since 6.4.0
|
|
186
|
+
*/
|
|
187
|
+
export declare function buildCacheKey(...parts: (string | number | boolean)[]): string;
|
|
188
|
+
//# sourceMappingURL=cache-helpers.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cache-helpers.d.ts","sourceRoot":"","sources":["../../../../src/services/shared/cache-helpers.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAEjD;;GAEG;AACH,MAAM,WAAW,gBAAgB,CAAC,CAAC,GAAG,MAAM;IAC1C,uCAAuC;IACvC,MAAM,CAAC,EAA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;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,wBAAgB,YAAY,CAAC,CAAC,EAAE,CAAC,EAC/B,EAAE,EAAE,CAAC,GAAG,EAAE,CAAC,KAAK,OAAO,CAAC,CAAC,CAAC,EAC1B,KAAK,EAAE,CAAC,GAAG,EAAE,CAAC,KAAK,MAAM,EACzB,KAAK,GAAE,MAAU,GAChB,CAAC,GAAG,EAAE,CAAC,KAAK,OAAO,CAAC,CAAC,CAAC,CAMxB;AAED;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,aAAa,CAAC,GAAG,KAAK,EAAE,CAAC,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC,EAAE,GAAG,MAAM,CAE7E"}
|
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* HTTP Helpers
|
|
3
|
+
*
|
|
4
|
+
* Shared utilities for HTTP operations across services.
|
|
5
|
+
* Eliminates duplicate try/catch error handling patterns found in 30+ methods.
|
|
6
|
+
*
|
|
7
|
+
* @category Services
|
|
8
|
+
* @since 6.4.0
|
|
9
|
+
*/
|
|
10
|
+
import type { Logger } from '../../utils/Logger';
|
|
11
|
+
/**
|
|
12
|
+
* Backend response shape accepted by error handling wrappers.
|
|
13
|
+
* More lenient than InternalApiResponse - accepts optional message field.
|
|
14
|
+
* @internal
|
|
15
|
+
*/
|
|
16
|
+
export interface BackendResponseLike<T = unknown> {
|
|
17
|
+
status: number;
|
|
18
|
+
error: boolean;
|
|
19
|
+
message?: string;
|
|
20
|
+
data?: T;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Options for withErrorHandling wrapper
|
|
24
|
+
*/
|
|
25
|
+
export interface WithErrorHandlingOptions {
|
|
26
|
+
/** Context message for error (e.g., "Failed to fetch pools") */
|
|
27
|
+
errorContext?: string;
|
|
28
|
+
/** Logger instance for debug output */
|
|
29
|
+
logger?: Logger;
|
|
30
|
+
/** Log level for operation start/end (debug only in debug mode) */
|
|
31
|
+
debugLogEnabled?: boolean;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Wraps an async HTTP operation with standardized error handling
|
|
35
|
+
*
|
|
36
|
+
* Handles try/catch pattern with optional logging in a single utility call.
|
|
37
|
+
*
|
|
38
|
+
* @typeParam T - The expected response data type
|
|
39
|
+
* @param operation - Async function that performs the HTTP operation
|
|
40
|
+
* @param options - Optional configuration for error handling
|
|
41
|
+
* @returns Promise resolving to the extracted data
|
|
42
|
+
*
|
|
43
|
+
* @example Basic usage
|
|
44
|
+
* ```typescript
|
|
45
|
+
* const data = await withErrorHandling(
|
|
46
|
+
* () => this.http.get<InternalApiResponse<UserData>>(endpoint),
|
|
47
|
+
* { errorContext: 'Failed to fetch user data' }
|
|
48
|
+
* );
|
|
49
|
+
* ```
|
|
50
|
+
*
|
|
51
|
+
* @example With logging
|
|
52
|
+
* ```typescript
|
|
53
|
+
* const data = await withErrorHandling(
|
|
54
|
+
* () => this.http.post<InternalApiResponse<Result>>(endpoint, body),
|
|
55
|
+
* { errorContext: 'Failed to create resource', logger: this.logger, debugLogEnabled: true }
|
|
56
|
+
* );
|
|
57
|
+
* ```
|
|
58
|
+
*
|
|
59
|
+
* @since 6.4.0
|
|
60
|
+
*/
|
|
61
|
+
export declare function withErrorHandling<T>(operation: () => Promise<BackendResponseLike<T>>, options?: WithErrorHandlingOptions): Promise<T>;
|
|
62
|
+
/**
|
|
63
|
+
* Wraps an async HTTP operation that returns raw data (no API wrapper)
|
|
64
|
+
*
|
|
65
|
+
* For operations that don't use the InternalApiResponse wrapper.
|
|
66
|
+
*
|
|
67
|
+
* @typeParam T - The expected response data type
|
|
68
|
+
* @param operation - Async function that performs the HTTP operation
|
|
69
|
+
* @param options - Optional configuration for error handling
|
|
70
|
+
* @returns Promise resolving to the raw response data
|
|
71
|
+
*
|
|
72
|
+
* @example
|
|
73
|
+
* ```typescript
|
|
74
|
+
* const data = await withErrorHandlingRaw(
|
|
75
|
+
* () => this.http.get<UserData>(endpoint),
|
|
76
|
+
* { errorContext: 'Failed to fetch user data', logger: this.logger }
|
|
77
|
+
* );
|
|
78
|
+
* ```
|
|
79
|
+
*
|
|
80
|
+
* @since 6.4.0
|
|
81
|
+
*/
|
|
82
|
+
export declare function withErrorHandlingRaw<T>(operation: () => Promise<T>, options?: WithErrorHandlingOptions): Promise<T>;
|
|
83
|
+
/**
|
|
84
|
+
* Wraps an async HTTP operation and returns the validated full response
|
|
85
|
+
*
|
|
86
|
+
* Unlike withErrorHandling which extracts response.data, this returns the full
|
|
87
|
+
* InternalApiResponse after validation. Useful when you need access to response
|
|
88
|
+
* properties like count, total, or status.
|
|
89
|
+
*
|
|
90
|
+
* @typeParam T - The expected response data type
|
|
91
|
+
* @param operation - Async function that performs the HTTP operation
|
|
92
|
+
* @param options - Optional configuration for error handling
|
|
93
|
+
* @returns Promise resolving to the full validated response
|
|
94
|
+
*
|
|
95
|
+
* @example
|
|
96
|
+
* ```typescript
|
|
97
|
+
* const response = await withResponseValidation(
|
|
98
|
+
* () => this.http.get<InternalApiResponse<PoolsData>>(endpoint, params),
|
|
99
|
+
* { errorContext: 'Failed to fetch pools' }
|
|
100
|
+
* );
|
|
101
|
+
* const pools = normalizePoolResponse(response.data!);
|
|
102
|
+
* const total = response.data!.count ?? 0;
|
|
103
|
+
* ```
|
|
104
|
+
*
|
|
105
|
+
* @since 6.5.0
|
|
106
|
+
*/
|
|
107
|
+
export declare function withResponseValidation<T>(operation: () => Promise<BackendResponseLike<T>>, options?: WithErrorHandlingOptions): Promise<BackendResponseLike<T>>;
|
|
108
|
+
/**
|
|
109
|
+
* Type for HTTP method functions
|
|
110
|
+
*/
|
|
111
|
+
export type HttpMethod = 'get' | 'post' | 'put' | 'patch' | 'delete';
|
|
112
|
+
/**
|
|
113
|
+
* Creates a type-safe HTTP request executor with error handling
|
|
114
|
+
*
|
|
115
|
+
* Factory function for creating reusable HTTP executors within services.
|
|
116
|
+
* Reduces boilerplate when services make many HTTP calls with similar patterns.
|
|
117
|
+
*
|
|
118
|
+
* @param http - HttpClient instance
|
|
119
|
+
* @param logger - Optional logger for debug output
|
|
120
|
+
* @returns Executor function for making HTTP requests
|
|
121
|
+
*
|
|
122
|
+
* @example
|
|
123
|
+
* ```typescript
|
|
124
|
+
* class MyService extends BaseService {
|
|
125
|
+
* private execute = createHttpExecutor(this.http, this.logger);
|
|
126
|
+
*
|
|
127
|
+
* async getUser(id: string) {
|
|
128
|
+
* return this.execute<UserData>('get', `/users/${id}`, 'Failed to get user');
|
|
129
|
+
* }
|
|
130
|
+
*
|
|
131
|
+
* async createUser(data: UserInput) {
|
|
132
|
+
* return this.execute<UserData>('post', '/users', 'Failed to create user', data);
|
|
133
|
+
* }
|
|
134
|
+
* }
|
|
135
|
+
* ```
|
|
136
|
+
*
|
|
137
|
+
* @since 6.4.0
|
|
138
|
+
*/
|
|
139
|
+
export declare function createHttpExecutor(http: {
|
|
140
|
+
get: <T>(url: string, params?: Record<string, unknown>, headers?: Record<string, string>) => Promise<T>;
|
|
141
|
+
post: <T>(url: string, data?: unknown, headers?: Record<string, string>) => Promise<T>;
|
|
142
|
+
put: <T>(url: string, data?: unknown, headers?: Record<string, string>) => Promise<T>;
|
|
143
|
+
patch: <T>(url: string, data?: unknown, headers?: Record<string, string>) => Promise<T>;
|
|
144
|
+
delete: <T>(url: string, params?: Record<string, unknown> | undefined, headers?: Record<string, string>) => Promise<T>;
|
|
145
|
+
}, logger?: Logger): <T>(method: HttpMethod, url: string, errorContext: string, dataOrParams?: unknown, headers?: Record<string, string>) => Promise<T>;
|
|
146
|
+
//# sourceMappingURL=http-helpers.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"http-helpers.d.ts","sourceRoot":"","sources":["../../../../src/services/shared/http-helpers.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAKH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAEjD;;;;GAIG;AACH,MAAM,WAA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