@gala-chain/launchpad-sdk 8.1.0 → 9.0.0-rc.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/CHANGELOG.md +837 -0
- package/EXAMPLES.md +95 -681
- package/MIGRATING-TO-9.0.md +343 -0
- package/README.md +46 -17
- package/dist/LaunchpadSDK.d.ts +536 -616
- package/dist/LaunchpadSDK.d.ts.map +1 -1
- package/dist/api/LaunchpadAPI.d.ts +6 -176
- package/dist/api/LaunchpadAPI.d.ts.map +1 -1
- package/dist/auth/SessionAuthService.d.ts +32 -2
- package/dist/auth/SessionAuthService.d.ts.map +1 -1
- package/dist/auth/SignatureAuth.d.ts +2 -2
- package/dist/auth/SignatureAuth.d.ts.map +1 -1
- package/dist/auth/session.d.ts +59 -0
- package/dist/auth/session.d.ts.map +1 -0
- package/dist/auth/types.d.ts +7 -2
- package/dist/auth/types.d.ts.map +1 -1
- package/dist/config/environments.d.ts +7 -2
- package/dist/config/environments.d.ts.map +1 -1
- package/dist/constants/decimals.d.ts +0 -23
- package/dist/constants/decimals.d.ts.map +1 -1
- package/dist/constants/endpoints.d.ts +19 -8
- package/dist/constants/endpoints.d.ts.map +1 -1
- package/dist/constants/enums.d.ts +19 -0
- package/dist/constants/enums.d.ts.map +1 -1
- package/dist/constants/version.generated.d.ts +1 -1
- package/dist/constants/version.generated.d.ts.map +1 -1
- package/dist/errors/LaunchpadSDKError.d.ts +18 -0
- package/dist/errors/LaunchpadSDKError.d.ts.map +1 -1
- package/dist/helpers/sdk.d.ts.map +1 -1
- package/dist/index.browser.d.ts +40 -45
- package/dist/index.browser.d.ts.map +1 -1
- package/dist/index.browser.esm.js +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.esm.js +1 -1
- package/dist/index.js +1 -1
- package/dist/index.node.d.ts +4 -5
- package/dist/index.node.d.ts.map +1 -1
- package/dist/launchpad/bundle-submission.d.ts +57 -10
- package/dist/launchpad/bundle-submission.d.ts.map +1 -1
- package/dist/launchpad/create-sale-validation.d.ts +19 -0
- package/dist/launchpad/create-sale-validation.d.ts.map +1 -0
- package/dist/launchpad/transport.d.ts +33 -2
- package/dist/launchpad/transport.d.ts.map +1 -1
- package/dist/launchpad/writes.d.ts +37 -11
- package/dist/launchpad/writes.d.ts.map +1 -1
- package/dist/native.cjs +1 -1
- package/dist/native.d.ts +4 -5
- package/dist/native.d.ts.map +1 -1
- package/dist/native.esm.js +1 -1
- package/dist/schemas/launchpad.d.ts +3 -2
- package/dist/schemas/launchpad.d.ts.map +1 -1
- package/dist/schemas/primitives.d.ts +12 -2
- package/dist/schemas/primitives.d.ts.map +1 -1
- package/dist/schemas/user.d.ts +3 -18
- package/dist/schemas/user.d.ts.map +1 -1
- package/dist/schemas/validators.d.ts +3 -3
- package/dist/services/AbstractCacheService.d.ts +2 -2
- package/dist/services/ApiKeyService.d.ts +1 -1
- package/dist/services/BanService.d.ts +1 -1
- package/dist/services/ChartService.d.ts.map +1 -1
- package/dist/services/ContentReactionService.d.ts +6 -18
- package/dist/services/ContentReactionService.d.ts.map +1 -1
- package/dist/services/EventsQueryService.d.ts +47 -0
- package/dist/services/EventsQueryService.d.ts.map +1 -0
- package/dist/services/GalaChainBalanceService.d.ts +17 -89
- package/dist/services/GalaChainBalanceService.d.ts.map +1 -1
- package/dist/services/GalaChainLockService.d.ts +19 -20
- package/dist/services/GalaChainLockService.d.ts.map +1 -1
- package/dist/services/GalaChainService.d.ts +28 -15
- package/dist/services/GalaChainService.d.ts.map +1 -1
- package/dist/services/GalaChainTokenService.d.ts +25 -53
- package/dist/services/GalaChainTokenService.d.ts.map +1 -1
- package/dist/services/GalaChainTransferService.d.ts +42 -41
- package/dist/services/GalaChainTransferService.d.ts.map +1 -1
- package/dist/services/HealthService.d.ts +33 -0
- package/dist/services/HealthService.d.ts.map +1 -0
- package/dist/services/ImageService.d.ts +3 -3
- package/dist/services/ImageService.d.ts.map +1 -1
- package/dist/services/LaunchpadPriceService.d.ts +66 -0
- package/dist/services/LaunchpadPriceService.d.ts.map +1 -0
- package/dist/services/LaunchpadService.d.ts +34 -42
- package/dist/services/LaunchpadService.d.ts.map +1 -1
- package/dist/services/MessagesService.d.ts +12 -44
- package/dist/services/MessagesService.d.ts.map +1 -1
- package/dist/services/ModeratorService.d.ts +2 -2
- package/dist/services/ModeratorService.d.ts.map +1 -1
- package/dist/services/NftCollectionService.d.ts +22 -6
- package/dist/services/NftCollectionService.d.ts.map +1 -1
- package/dist/services/OverseerService.d.ts +3 -3
- package/dist/services/OverseerService.d.ts.map +1 -1
- package/dist/services/PlatformStatsService.d.ts +1 -2
- package/dist/services/PlatformStatsService.d.ts.map +1 -1
- package/dist/services/PoolService.d.ts +28 -65
- package/dist/services/PoolService.d.ts.map +1 -1
- package/dist/services/RestrictedNamesService.d.ts +1 -1
- package/dist/services/RestrictedNamesService.d.ts.map +1 -1
- package/dist/services/StreamChatService.d.ts +8 -19
- package/dist/services/StreamChatService.d.ts.map +1 -1
- package/dist/services/StreamTokenServiceBase.d.ts +2 -1
- package/dist/services/StreamTokenServiceBase.d.ts.map +1 -1
- package/dist/services/StreamWebSocketService.d.ts +423 -451
- package/dist/services/StreamWebSocketService.d.ts.map +1 -1
- package/dist/services/StreamingService.d.ts +14 -15
- package/dist/services/StreamingService.d.ts.map +1 -1
- package/dist/services/TokenBanService.d.ts +1 -1
- package/dist/services/TokenResolverService.d.ts +5 -5
- package/dist/services/TokenResolverService.d.ts.map +1 -1
- package/dist/services/TradeService.d.ts +13 -9
- package/dist/services/TradeService.d.ts.map +1 -1
- package/dist/services/TradingQuotesService.d.ts.map +1 -1
- package/dist/services/UserService.d.ts +64 -20
- package/dist/services/UserService.d.ts.map +1 -1
- package/dist/services/gateway-transport.d.ts +32 -0
- package/dist/services/gateway-transport.d.ts.map +1 -0
- package/dist/services/gateway-writes.d.ts +83 -0
- package/dist/services/gateway-writes.d.ts.map +1 -0
- package/dist/services/realtime/event-catalog.d.ts +456 -0
- package/dist/services/realtime/event-catalog.d.ts.map +1 -0
- package/dist/services/shared/pagination-helpers.d.ts +22 -5
- package/dist/services/shared/pagination-helpers.d.ts.map +1 -1
- package/dist/services/shared/service-validators.d.ts.map +1 -1
- package/dist/signing/index.d.ts +2 -3
- package/dist/signing/index.d.ts.map +1 -1
- package/dist/signing/signers.d.ts +64 -9
- package/dist/signing/signers.d.ts.map +1 -1
- package/dist/signing/types.d.ts +7 -10
- package/dist/signing/types.d.ts.map +1 -1
- package/dist/types/api-key.dto.d.ts +1 -1
- package/dist/types/ban.dto.d.ts +21 -16
- package/dist/types/ban.dto.d.ts.map +1 -1
- package/dist/types/burn.dto.d.ts +4 -2
- package/dist/types/burn.dto.d.ts.map +1 -1
- package/dist/types/chat-messages.dto.d.ts +10 -72
- package/dist/types/chat-messages.dto.d.ts.map +1 -1
- package/dist/types/comments.dto.d.ts +8 -78
- package/dist/types/comments.dto.d.ts.map +1 -1
- package/dist/types/common.d.ts +42 -85
- package/dist/types/common.d.ts.map +1 -1
- package/dist/types/constraints.d.ts +47 -23
- package/dist/types/constraints.d.ts.map +1 -1
- package/dist/types/content-flag.dto.d.ts +5 -1
- package/dist/types/content-flag.dto.d.ts.map +1 -1
- package/dist/types/content-reactions.dto.d.ts +0 -4
- package/dist/types/content-reactions.dto.d.ts.map +1 -1
- package/dist/types/dto.d.ts +0 -5
- package/dist/types/dto.d.ts.map +1 -1
- package/dist/types/engagement-stats.dto.d.ts +16 -27
- package/dist/types/engagement-stats.dto.d.ts.map +1 -1
- package/dist/types/events.dto.d.ts +89 -0
- package/dist/types/events.dto.d.ts.map +1 -1
- package/dist/types/global-feed.dto.d.ts +23 -164
- package/dist/types/global-feed.dto.d.ts.map +1 -1
- package/dist/types/health.dto.d.ts +32 -0
- package/dist/types/health.dto.d.ts.map +1 -0
- package/dist/types/launchpad.dto.d.ts +77 -323
- package/dist/types/launchpad.dto.d.ts.map +1 -1
- package/dist/types/lock.dto.d.ts +12 -7
- package/dist/types/lock.dto.d.ts.map +1 -1
- package/dist/types/messages.dto.d.ts +168 -118
- package/dist/types/messages.dto.d.ts.map +1 -1
- package/dist/types/moderator.dto.d.ts +1 -1
- package/dist/types/options.dto.d.ts +8 -36
- package/dist/types/options.dto.d.ts.map +1 -1
- package/dist/types/overseer.dto.d.ts +2 -1
- package/dist/types/overseer.dto.d.ts.map +1 -1
- package/dist/types/platform-stats.dto.d.ts +3 -3
- package/dist/types/realtime-events.dto.d.ts +340 -0
- package/dist/types/realtime-events.dto.d.ts.map +1 -0
- package/dist/types/restricted-names.dto.d.ts +2 -2
- package/dist/types/restricted-names.dto.d.ts.map +1 -1
- package/dist/types/stream-chat.dto.d.ts +15 -14
- package/dist/types/stream-chat.dto.d.ts.map +1 -1
- package/dist/types/streaming.dto.d.ts +73 -104
- package/dist/types/streaming.dto.d.ts.map +1 -1
- package/dist/types/token-ban.dto.d.ts.map +1 -1
- package/dist/types/token-config.dto.d.ts +34 -19
- package/dist/types/token-config.dto.d.ts.map +1 -1
- package/dist/types/trades-query.dto.d.ts +8 -24
- package/dist/types/trades-query.dto.d.ts.map +1 -1
- package/dist/types/user.dto.d.ts +133 -112
- package/dist/types/user.dto.d.ts.map +1 -1
- package/dist/types/websocket-events.dto.d.ts +5 -5
- package/dist/types/websocket-events.dto.d.ts.map +1 -1
- package/dist/utils/address-formatter.d.ts +25 -2
- package/dist/utils/address-formatter.d.ts.map +1 -1
- package/dist/utils/agent-config.d.ts +9 -4
- package/dist/utils/agent-config.d.ts.map +1 -1
- package/dist/utils/auto-pagination.d.ts +7 -240
- package/dist/utils/auto-pagination.d.ts.map +1 -1
- package/dist/utils/bignumber-helpers.d.ts +3 -2
- package/dist/utils/bignumber-helpers.d.ts.map +1 -1
- package/dist/utils/delimiter-parser.d.ts +0 -13
- package/dist/utils/delimiter-parser.d.ts.map +1 -1
- package/dist/utils/error-factories.d.ts +4 -3
- package/dist/utils/error-factories.d.ts.map +1 -1
- package/dist/utils/error-patterns.d.ts +0 -47
- package/dist/utils/error-patterns.d.ts.map +1 -1
- package/dist/utils/error-wrapper.d.ts +5 -5
- package/dist/utils/errors.d.ts +53 -318
- package/dist/utils/errors.d.ts.map +1 -1
- package/dist/utils/http.d.ts +36 -3
- package/dist/utils/http.d.ts.map +1 -1
- package/dist/utils/message-validators.d.ts.map +1 -1
- package/dist/utils/pagination-helpers.d.ts +17 -0
- package/dist/utils/pagination-helpers.d.ts.map +1 -1
- package/dist/utils/pagination-validation.d.ts +2 -2
- package/dist/utils/response-handlers.d.ts.map +1 -1
- package/dist/utils/service-validators.d.ts +6 -6
- package/dist/utils/service-validators.d.ts.map +1 -1
- package/dist/utils/token-format-converter.d.ts +1 -1
- package/dist/utils/token-parser.d.ts +6 -127
- package/dist/utils/token-parser.d.ts.map +1 -1
- package/dist/utils/token-stringification.d.ts +7 -7
- package/dist/utils/token-stringification.d.ts.map +1 -1
- package/dist/utils/tokenNameNormalizer.d.ts +2 -2
- package/dist/utils/tokenNormalizer.d.ts +5 -29
- package/dist/utils/tokenNormalizer.d.ts.map +1 -1
- package/dist/utils/unique-key-generator.d.ts +7 -134
- package/dist/utils/unique-key-generator.d.ts.map +1 -1
- package/dist/utils/validation-helpers.d.ts +21 -64
- package/dist/utils/validation-helpers.d.ts.map +1 -1
- package/dist/utils/validation.d.ts +4 -1
- package/dist/utils/validation.d.ts.map +1 -1
- package/package.json +47 -87
- package/dist/api/dto/BurnTokensDto.d.ts +0 -77
- package/dist/api/dto/BurnTokensDto.d.ts.map +0 -1
- package/dist/api/dto/LockTokenDto.d.ts +0 -85
- package/dist/api/dto/LockTokenDto.d.ts.map +0 -1
- package/dist/api/dto/TransferTokenDto.d.ts +0 -64
- package/dist/api/dto/TransferTokenDto.d.ts.map +0 -1
- package/dist/api/dto/UnlockTokenDto.d.ts +0 -74
- package/dist/api/dto/UnlockTokenDto.d.ts.map +0 -1
- package/dist/bridge/BridgeService.d.ts +0 -484
- package/dist/bridge/BridgeService.d.ts.map +0 -1
- package/dist/bridge/GalaConnectClient.d.ts +0 -170
- package/dist/bridge/GalaConnectClient.d.ts.map +0 -1
- package/dist/bridge/constants/index.d.ts +0 -7
- package/dist/bridge/constants/index.d.ts.map +0 -1
- package/dist/bridge/constants/tokens.d.ts +0 -212
- package/dist/bridge/constants/tokens.d.ts.map +0 -1
- package/dist/bridge/index.d.ts +0 -24
- package/dist/bridge/index.d.ts.map +0 -1
- package/dist/bridge/public-types.d.ts +0 -2
- package/dist/bridge/public-types.d.ts.map +0 -1
- package/dist/bridge/strategies/BridgeStrategy.d.ts +0 -204
- package/dist/bridge/strategies/BridgeStrategy.d.ts.map +0 -1
- package/dist/bridge/strategies/EthereumBridgeStrategy.d.ts +0 -178
- package/dist/bridge/strategies/EthereumBridgeStrategy.d.ts.map +0 -1
- package/dist/bridge/strategies/SolanaBridgeStrategy.d.ts +0 -236
- package/dist/bridge/strategies/SolanaBridgeStrategy.d.ts.map +0 -1
- package/dist/bridge/types/bridge.dto.d.ts +0 -772
- package/dist/bridge/types/bridge.dto.d.ts.map +0 -1
- package/dist/bridge/types/bridgeable-token.dto.d.ts +0 -209
- package/dist/bridge/types/bridgeable-token.dto.d.ts.map +0 -1
- package/dist/bridge/types/eip712.d.ts +0 -66
- package/dist/bridge/types/eip712.d.ts.map +0 -1
- package/dist/bridge/types/index.d.ts +0 -8
- package/dist/bridge/types/index.d.ts.map +0 -1
- package/dist/bridge/utils/RateLimiter.d.ts +0 -34
- package/dist/bridge/utils/RateLimiter.d.ts.map +0 -1
- package/dist/bridge/utils/address-formatter.d.ts +0 -25
- package/dist/bridge/utils/address-formatter.d.ts.map +0 -1
- package/dist/bridge/utils/addressValidation.d.ts +0 -200
- package/dist/bridge/utils/addressValidation.d.ts.map +0 -1
- package/dist/bridge/utils/balanceHelpers.d.ts +0 -215
- package/dist/bridge/utils/balanceHelpers.d.ts.map +0 -1
- package/dist/bridge/utils/bridgeErrors.d.ts +0 -98
- package/dist/bridge/utils/bridgeErrors.d.ts.map +0 -1
- package/dist/bridge/utils/bridgeOutHelpers.d.ts +0 -68
- package/dist/bridge/utils/bridgeOutHelpers.d.ts.map +0 -1
- package/dist/bridge/utils/bridgePayload.d.ts +0 -98
- package/dist/bridge/utils/bridgePayload.d.ts.map +0 -1
- package/dist/bridge/utils/bridgeStatusParser.d.ts +0 -76
- package/dist/bridge/utils/bridgeStatusParser.d.ts.map +0 -1
- package/dist/bridge/utils/eip712Helpers.d.ts +0 -66
- package/dist/bridge/utils/eip712Helpers.d.ts.map +0 -1
- package/dist/bridge/utils/index.d.ts +0 -19
- package/dist/bridge/utils/index.d.ts.map +0 -1
- package/dist/bridge/utils/retry.d.ts +0 -112
- package/dist/bridge/utils/retry.d.ts.map +0 -1
- package/dist/bridge/utils/strategyDelegation.d.ts +0 -126
- package/dist/bridge/utils/strategyDelegation.d.ts.map +0 -1
- package/dist/bridge/utils/tokenIdUtils.d.ts +0 -86
- package/dist/bridge/utils/tokenIdUtils.d.ts.map +0 -1
- package/dist/bridge/utils/tokenMath.d.ts +0 -39
- package/dist/bridge/utils/tokenMath.d.ts.map +0 -1
- package/dist/bridge/utils/tokenMetadataResolver.d.ts +0 -97
- package/dist/bridge/utils/tokenMetadataResolver.d.ts.map +0 -1
- package/dist/helpers/wallet.d.ts +0 -151
- package/dist/helpers/wallet.d.ts.map +0 -1
- package/dist/react/WalletContext.d.ts +0 -60
- package/dist/react/WalletContext.d.ts.map +0 -1
- package/dist/react/index.d.ts +0 -65
- package/dist/react/index.d.ts.map +0 -1
- package/dist/react/types.d.ts +0 -76
- package/dist/react/types.d.ts.map +0 -1
- package/dist/react/useWallet.d.ts +0 -123
- package/dist/react/useWallet.d.ts.map +0 -1
- package/dist/react/useWalletConnection.d.ts +0 -89
- package/dist/react/useWalletConnection.d.ts.map +0 -1
- package/dist/react/useWalletDetection.d.ts +0 -81
- package/dist/react/useWalletDetection.d.ts.map +0 -1
- package/dist/react.cjs +0 -1
- package/dist/react.esm.js +0 -1
- package/dist/services/AbstractTokenFetchService.d.ts +0 -150
- package/dist/services/AbstractTokenFetchService.d.ts.map +0 -1
- package/dist/services/BatchedCacheService.d.ts +0 -133
- package/dist/services/BatchedCacheService.d.ts.map +0 -1
- package/dist/services/BridgeableTokenCache.d.ts +0 -120
- package/dist/services/BridgeableTokenCache.d.ts.map +0 -1
- package/dist/services/BridgeableTokenService.d.ts +0 -218
- package/dist/services/BridgeableTokenService.d.ts.map +0 -1
- package/dist/services/DexService.d.ts +0 -440
- package/dist/services/DexService.d.ts.map +0 -1
- package/dist/services/NetworkKeyedCacheService.d.ts +0 -185
- package/dist/services/NetworkKeyedCacheService.d.ts.map +0 -1
- package/dist/services/PriceHistoryService.d.ts +0 -209
- package/dist/services/PriceHistoryService.d.ts.map +0 -1
- package/dist/services/StreamingEventService.d.ts +0 -441
- package/dist/services/StreamingEventService.d.ts.map +0 -1
- package/dist/services/WrapService.d.ts +0 -171
- package/dist/services/WrapService.d.ts.map +0 -1
- package/dist/services/WrappableTokenCache.d.ts +0 -100
- package/dist/services/WrappableTokenCache.d.ts.map +0 -1
- package/dist/services/WrappableTokenService.d.ts +0 -130
- package/dist/services/WrappableTokenService.d.ts.map +0 -1
- package/dist/setup.d.ts +0 -8
- package/dist/setup.d.ts.map +0 -1
- package/dist/tokens/transfers.d.ts +0 -95
- package/dist/tokens/transfers.d.ts.map +0 -1
- package/dist/types/comment.dto.d.ts +0 -176
- package/dist/types/comment.dto.d.ts.map +0 -1
- package/dist/types/galachain-api.types.d.ts +0 -297
- package/dist/types/galachain-api.types.d.ts.map +0 -1
- package/dist/types/priceHistory.dto.d.ts +0 -134
- package/dist/types/priceHistory.dto.d.ts.map +0 -1
- package/dist/types/streaming-events.dto.d.ts +0 -605
- package/dist/types/streaming-events.dto.d.ts.map +0 -1
- package/dist/types/token.types.d.ts +0 -359
- package/dist/types/token.types.d.ts.map +0 -1
- package/dist/types/wrappable-token.dto.d.ts +0 -305
- package/dist/types/wrappable-token.dto.d.ts.map +0 -1
- package/dist/utils/crypto-compat.d.ts +0 -40
- package/dist/utils/crypto-compat.d.ts.map +0 -1
- package/dist/utils/load-env.d.ts +0 -31
- package/dist/utils/load-env.d.ts.map +0 -1
- package/dist/utils/token-instance-key.d.ts +0 -57
- package/dist/utils/token-instance-key.d.ts.map +0 -1
- package/dist/utils/wallet.d.ts +0 -166
- package/dist/utils/wallet.d.ts.map +0 -1
- package/dist/wallet/ExternalWalletProvider.d.ts +0 -90
- package/dist/wallet/ExternalWalletProvider.d.ts.map +0 -1
- package/dist/wallet/GalaWalletProvider.d.ts +0 -122
- package/dist/wallet/GalaWalletProvider.d.ts.map +0 -1
- package/dist/wallet/PrivateKeyProvider.d.ts +0 -90
- package/dist/wallet/PrivateKeyProvider.d.ts.map +0 -1
- package/dist/wallet/detection.d.ts +0 -107
- package/dist/wallet/detection.d.ts.map +0 -1
- package/dist/wallet/event-handlers.d.ts +0 -50
- package/dist/wallet/event-handlers.d.ts.map +0 -1
- package/dist/wallet/index.d.ts +0 -51
- package/dist/wallet/index.d.ts.map +0 -1
- package/dist/wallet/signing-operation.d.ts +0 -19
- package/dist/wallet/signing-operation.d.ts.map +0 -1
- package/dist/wallet/typed-data-helpers.d.ts +0 -68
- package/dist/wallet/typed-data-helpers.d.ts.map +0 -1
- package/dist/wallet/types.d.ts +0 -267
- package/dist/wallet/types.d.ts.map +0 -1
- package/dist/wallet/utils.d.ts +0 -117
- package/dist/wallet/utils.d.ts.map +0 -1
- package/dist/wallet.cjs +0 -1
- package/dist/wallet.esm.js +0 -1
|
@@ -7,13 +7,13 @@
|
|
|
7
7
|
* - Dollar with $ in collection: "$MUSIC$Unit$none$none" (parses from END)
|
|
8
8
|
*
|
|
9
9
|
* CRITICAL SECURITY NOTE:
|
|
10
|
-
* Plain strings like "GALA" are
|
|
11
|
-
*
|
|
12
|
-
*
|
|
10
|
+
* Plain strings like "GALA" are not token formats: a caller detects the delimiter
|
|
11
|
+
* (`isPipeDelimited` / `isDollarDelimited`) and parses with the matching parser.
|
|
12
|
+
* The object guard for a token class key is gala-core-sdk's `isTokenClassKey`.
|
|
13
13
|
*
|
|
14
14
|
* @packageDocumentation
|
|
15
15
|
*/
|
|
16
|
-
import type {
|
|
16
|
+
import type { GalaChainTokenClassKey } from '@gala-chain/gala-core-sdk';
|
|
17
17
|
/**
|
|
18
18
|
* PERFORMANCE CHARACTERISTICS:
|
|
19
19
|
*
|
|
@@ -21,10 +21,6 @@ import type { TokenClassKey } from '../types/common';
|
|
|
21
21
|
* - Pipe-delimited tokens: Direct split() call, minimal string operations
|
|
22
22
|
* - Dollar-delimited tokens: Reverse algorithm, ~2x string operations
|
|
23
23
|
*
|
|
24
|
-
* Slow-path (format detection):
|
|
25
|
-
* - Plain strings without delimiters: Requires fallback logic
|
|
26
|
-
* - Type validation: Object instanceof checks for already-parsed tokens
|
|
27
|
-
*
|
|
28
24
|
* Recommendation: Pre-detect format when parsing large token batches:
|
|
29
25
|
* ```typescript
|
|
30
26
|
* import { isPipeDelimited, isDollarDelimited } from './token-parser';
|
|
@@ -36,61 +32,12 @@ import type { TokenClassKey } from '../types/common';
|
|
|
36
32
|
* }
|
|
37
33
|
* ```
|
|
38
34
|
*/
|
|
39
|
-
/**
|
|
40
|
-
* Parse token from ANY format (pipe/dollar delimited) into TokenClassKey
|
|
41
|
-
*
|
|
42
|
-
* Accepts:
|
|
43
|
-
* - Pipe format: "GALA|Unit|none|none"
|
|
44
|
-
* - Dollar format: "GALA$Unit$none$none"
|
|
45
|
-
* - Dollar with $ in collection: "$MUSIC$Unit$none$none"
|
|
46
|
-
* - TokenClassKey objects: { collection, category, type, additionalKey }
|
|
47
|
-
*
|
|
48
|
-
* REJECTS:
|
|
49
|
-
* - Plain strings like "GALA" (DANGEROUS - no delimiters!)
|
|
50
|
-
* - Null/undefined values
|
|
51
|
-
* - Invalid formats
|
|
52
|
-
*
|
|
53
|
-
* ⚠️ SECURITY ENFORCEMENT (v3.33.0+):
|
|
54
|
-
* Plain token strings are NO LONGER accepted. All tokens must use explicit delimiters.
|
|
55
|
-
* This is a breaking change to enforce secure token format validation.
|
|
56
|
-
*
|
|
57
|
-
* @param token Token string to parse
|
|
58
|
-
* @returns TokenClassKey with { collection, category, type, additionalKey }
|
|
59
|
-
* @throws ValidationError if format is invalid or if plain string is provided
|
|
60
|
-
*
|
|
61
|
-
* @example
|
|
62
|
-
* ```typescript
|
|
63
|
-
* // Pipe-delimited (RECOMMENDED)
|
|
64
|
-
* parseToken("GALA|Unit|none|none")
|
|
65
|
-
* // → { collection: "GALA", category: "Unit", type: "none", additionalKey: "none" }
|
|
66
|
-
*
|
|
67
|
-
* // Dollar-delimited
|
|
68
|
-
* parseToken("GALA$Unit$none$none")
|
|
69
|
-
* // → { collection: "GALA", category: "Unit", type: "none", additionalKey: "none" }
|
|
70
|
-
*
|
|
71
|
-
* // Dollar with $ in collection (EDGE CASE)
|
|
72
|
-
* parseToken("$MUSIC$Unit$none$none")
|
|
73
|
-
* // → { collection: "$MUSIC", category: "Unit", type: "none", additionalKey: "none" }
|
|
74
|
-
*
|
|
75
|
-
* // TokenClassKey object
|
|
76
|
-
* parseToken({ collection: "GALA", category: "Unit", type: "none", additionalKey: "none" })
|
|
77
|
-
* // → { collection: "GALA", category: "Unit", type: "none", additionalKey: "none" }
|
|
78
|
-
*
|
|
79
|
-
* // Plain string - PERMANENTLY REJECTED
|
|
80
|
-
* parseToken("GALA") // Throws ValidationError
|
|
81
|
-
* ```
|
|
82
|
-
*
|
|
83
|
-
* @since 3.32.0
|
|
84
|
-
* @updated 3.33.0 - Removed allowPlainStrings parameter, enforce strict delimiter-only parsing
|
|
85
|
-
*/
|
|
86
|
-
export declare function parseToken(token: string | TokenClassKey | undefined | null): TokenClassKey;
|
|
87
35
|
/**
|
|
88
36
|
* Parse pipe-delimited token: "GALA|Unit|none|none"
|
|
89
37
|
*
|
|
90
|
-
* @internal Used by parseToken()
|
|
91
38
|
* @throws ValidationError if format is invalid
|
|
92
39
|
*/
|
|
93
|
-
export declare function parsePipeDelimitedToken(token: string):
|
|
40
|
+
export declare function parsePipeDelimitedToken(token: string): GalaChainTokenClassKey;
|
|
94
41
|
/**
|
|
95
42
|
* REVERSE-PARSING ALGORITHM FOR DOLLAR-DELIMITED TOKENS
|
|
96
43
|
*
|
|
@@ -140,10 +87,9 @@ export declare function parsePipeDelimitedToken(token: string): TokenClassKey;
|
|
|
140
87
|
* - Last 3 parts (from right): category, type, additionalKey
|
|
141
88
|
* - Everything else: collection
|
|
142
89
|
*
|
|
143
|
-
* @internal Used by parseToken()
|
|
144
90
|
* @throws ValidationError if format is invalid
|
|
145
91
|
*/
|
|
146
|
-
export declare function parseDollarDelimitedToken(token: string):
|
|
92
|
+
export declare function parseDollarDelimitedToken(token: string): GalaChainTokenClassKey;
|
|
147
93
|
/**
|
|
148
94
|
* Check if token string is in pipe-delimited format
|
|
149
95
|
*
|
|
@@ -165,71 +111,4 @@ export declare function isPipeDelimited(token: string): boolean;
|
|
|
165
111
|
* ```
|
|
166
112
|
*/
|
|
167
113
|
export declare function isDollarDelimited(token: string): boolean;
|
|
168
|
-
/**
|
|
169
|
-
* Check if token is in ANY valid delimited format (pipe or dollar)
|
|
170
|
-
*
|
|
171
|
-
* @example
|
|
172
|
-
* ```typescript
|
|
173
|
-
* isDelimited("GALA|Unit|none|none") // → true
|
|
174
|
-
* isDelimited("GALA$Unit$none$none") // → true
|
|
175
|
-
* isDelimited("GALA") // → false
|
|
176
|
-
* ```
|
|
177
|
-
*/
|
|
178
|
-
export declare function isDelimited(token: string): boolean;
|
|
179
|
-
/**
|
|
180
|
-
* Check if a value is a valid token format (string OR TokenClassKey object)
|
|
181
|
-
*
|
|
182
|
-
* @param token Token to validate
|
|
183
|
-
* @returns true if token is valid format (pipe/dollar delimited OR TokenClassKey object)
|
|
184
|
-
*
|
|
185
|
-
* @example
|
|
186
|
-
* ```typescript
|
|
187
|
-
* isValidTokenFormat("GALA|Unit|none|none") // → true
|
|
188
|
-
* isValidTokenFormat("GALA$Unit$none$none") // → true
|
|
189
|
-
* isValidTokenFormat({ collection: "GALA", ... }) // → true
|
|
190
|
-
* isValidTokenFormat("GALA") // → false (plain string, not delimited)
|
|
191
|
-
* ```
|
|
192
|
-
*/
|
|
193
|
-
export declare function isValidTokenFormat(token: unknown): boolean;
|
|
194
|
-
/**
|
|
195
|
-
* Check if token is a plain symbol string (NOT a delimited format)
|
|
196
|
-
*
|
|
197
|
-
* Plain token symbols are simple strings like "GALA", "USDC", etc.
|
|
198
|
-
* These are REJECTED by default by parseToken() for security reasons.
|
|
199
|
-
* Use parseToken(symbol, true) to parse plain symbols.
|
|
200
|
-
*
|
|
201
|
-
* @param token Token to check
|
|
202
|
-
* @returns true if token is plain symbol (no delimiters)
|
|
203
|
-
*
|
|
204
|
-
* @example
|
|
205
|
-
* ```typescript
|
|
206
|
-
* isPlainTokenSymbol("GALA") // → true
|
|
207
|
-
* isPlainTokenSymbol("GALA|Unit|none|none") // → false
|
|
208
|
-
* isPlainTokenSymbol("GALA$Unit$none$none") // → false
|
|
209
|
-
* ```
|
|
210
|
-
*
|
|
211
|
-
* @security WARNING: Plain tokens are inherently ambiguous!
|
|
212
|
-
* Always use delimited formats when possible.
|
|
213
|
-
*/
|
|
214
|
-
export declare function isPlainTokenSymbol(token: unknown): boolean;
|
|
215
|
-
/**
|
|
216
|
-
* Type guard: Check if value is a TokenClassKey object
|
|
217
|
-
*
|
|
218
|
-
* @param token Value to check
|
|
219
|
-
* @returns true if token is a valid TokenClassKey object with all required properties
|
|
220
|
-
*
|
|
221
|
-
* @example
|
|
222
|
-
* ```typescript
|
|
223
|
-
* const value: string | TokenClassKey = getToken();
|
|
224
|
-
*
|
|
225
|
-
* if (isTokenClassKey(value)) {
|
|
226
|
-
* // TypeScript now knows value is TokenClassKey
|
|
227
|
-
* console.log(value.collection, value.category, value.type, value.additionalKey);
|
|
228
|
-
* } else {
|
|
229
|
-
* // value is string
|
|
230
|
-
* console.log(parseToken(value));
|
|
231
|
-
* }
|
|
232
|
-
* ```
|
|
233
|
-
*/
|
|
234
|
-
export declare function isTokenClassKey(token: unknown): token is TokenClassKey;
|
|
235
114
|
//# sourceMappingURL=token-parser.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"token-parser.d.ts","sourceRoot":"","sources":["../../src/utils/token-parser.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"token-parser.d.ts","sourceRoot":"","sources":["../../src/utils/token-parser.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,2BAA2B,CAAC;AAOxE;;;;;;;;;;;;;;;;;GAiBG;AAEH;;;;GAIG;AACH,wBAAgB,uBAAuB,CAAC,KAAK,EAAE,MAAM,GAAG,sBAAsB,CAG7E;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsCG;AAEH;;;;;;;;;;;GAWG;AACH,wBAAgB,yBAAyB,CAAC,KAAK,EAAE,MAAM,GAAG,sBAAsB,CAG/E;AAGD;;;;;;;;GAQG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAEtD;AAED;;;;;;;;;GASG;AACH,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAExD"}
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* @category Utilities
|
|
5
5
|
* @since 6.6.0
|
|
6
6
|
*/
|
|
7
|
-
import type {
|
|
7
|
+
import type { GalaChainTokenClassKey, GalaChainTokenInstanceKey } from '@gala-chain/gala-core-sdk';
|
|
8
8
|
/**
|
|
9
9
|
* Convert a TokenClassKey to pipe-delimited string format
|
|
10
10
|
*
|
|
@@ -37,7 +37,7 @@ import type { TokenClassKey, TokenInstanceKey } from '../types/common';
|
|
|
37
37
|
*
|
|
38
38
|
* @since 6.6.0
|
|
39
39
|
*/
|
|
40
|
-
export declare function stringifyTokenClassKey(token:
|
|
40
|
+
export declare function stringifyTokenClassKey(token: GalaChainTokenClassKey): string;
|
|
41
41
|
/**
|
|
42
42
|
* Convert a TokenInstanceKey to pipe-delimited string format (with instance)
|
|
43
43
|
*
|
|
@@ -63,7 +63,7 @@ export declare function stringifyTokenClassKey(token: TokenClassKey): string;
|
|
|
63
63
|
*
|
|
64
64
|
* @since 6.6.0
|
|
65
65
|
*/
|
|
66
|
-
export declare function stringifyTokenInstanceKey(token:
|
|
66
|
+
export declare function stringifyTokenInstanceKey(token: GalaChainTokenInstanceKey): string;
|
|
67
67
|
/**
|
|
68
68
|
* Convert either TokenClassKey or TokenInstanceKey to string
|
|
69
69
|
*
|
|
@@ -88,7 +88,7 @@ export declare function stringifyTokenInstanceKey(token: TokenInstanceKey): stri
|
|
|
88
88
|
*
|
|
89
89
|
* @since 6.6.0
|
|
90
90
|
*/
|
|
91
|
-
export declare function stringifyToken(token:
|
|
91
|
+
export declare function stringifyToken(token: GalaChainTokenClassKey | GalaChainTokenInstanceKey): string;
|
|
92
92
|
/**
|
|
93
93
|
* Convert TokenClassKey to dollar-delimited string format
|
|
94
94
|
*
|
|
@@ -113,7 +113,7 @@ export declare function stringifyToken(token: TokenClassKey | TokenInstanceKey):
|
|
|
113
113
|
*
|
|
114
114
|
* @since 6.7.0
|
|
115
115
|
*/
|
|
116
|
-
export declare function stringifyTokenClassKeyDollar(token:
|
|
116
|
+
export declare function stringifyTokenClassKeyDollar(token: GalaChainTokenClassKey): string;
|
|
117
117
|
/**
|
|
118
118
|
* Convert TokenInstanceKey to dollar-delimited string format (with instance)
|
|
119
119
|
*
|
|
@@ -139,7 +139,7 @@ export declare function stringifyTokenClassKeyDollar(token: TokenClassKey): stri
|
|
|
139
139
|
*
|
|
140
140
|
* @since 6.7.0
|
|
141
141
|
*/
|
|
142
|
-
export declare function stringifyTokenInstanceKeyDollar(token:
|
|
142
|
+
export declare function stringifyTokenInstanceKeyDollar(token: GalaChainTokenInstanceKey): string;
|
|
143
143
|
/**
|
|
144
144
|
* Convert TokenClassKey to dollar-delimited string format with prefix
|
|
145
145
|
*
|
|
@@ -163,5 +163,5 @@ export declare function stringifyTokenInstanceKeyDollar(token: TokenInstanceKey)
|
|
|
163
163
|
*
|
|
164
164
|
* @since 6.7.0
|
|
165
165
|
*/
|
|
166
|
-
export declare function stringifyTokenClassKeyDollarPrefixed(token:
|
|
166
|
+
export declare function stringifyTokenClassKeyDollarPrefixed(token: GalaChainTokenClassKey): string;
|
|
167
167
|
//# sourceMappingURL=token-stringification.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"token-stringification.d.ts","sourceRoot":"","sources":["../../src/utils/token-stringification.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"token-stringification.d.ts","sourceRoot":"","sources":["../../src/utils/token-stringification.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,sBAAsB,EAAE,yBAAyB,EAAE,MAAM,2BAA2B,CAAC;AAEnG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AACH,wBAAgB,sBAAsB,CAAC,KAAK,EAAE,sBAAsB,GAAG,MAAM,CAE5E;AAED;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,wBAAgB,yBAAyB,CAAC,KAAK,EAAE,yBAAyB,GAAG,MAAM,CAElF;AAED;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,sBAAsB,GAAG,yBAAyB,GAAG,MAAM,CAKhG;AAED;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,wBAAgB,4BAA4B,CAAC,KAAK,EAAE,sBAAsB,GAAG,MAAM,CAElF;AAED;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,wBAAgB,+BAA+B,CAAC,KAAK,EAAE,yBAAyB,GAAG,MAAM,CAExF;AAED;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wBAAgB,oCAAoC,CAAC,KAAK,EAAE,sBAAsB,GAAG,MAAM,CAE1F"}
|
|
@@ -35,8 +35,8 @@ export declare function normalizeTokenName(tokenName: string): string;
|
|
|
35
35
|
/**
|
|
36
36
|
* Normalizes a token identifier for consistent cache keys.
|
|
37
37
|
*
|
|
38
|
-
* Used by cache services (
|
|
39
|
-
*
|
|
38
|
+
* Used by the cache services (AbstractCacheService) for case-insensitive lookups of token
|
|
39
|
+
* symbols and tokenIds.
|
|
40
40
|
*
|
|
41
41
|
* Current normalizations:
|
|
42
42
|
* - `.trim()` - Remove leading/trailing whitespace
|
|
@@ -4,8 +4,8 @@
|
|
|
4
4
|
* This module provides utilities for normalizing different token identifier formats
|
|
5
5
|
* into a consistent TokenInstanceKey format that can be used with GalaChain APIs.
|
|
6
6
|
*/
|
|
7
|
-
import
|
|
8
|
-
import {
|
|
7
|
+
import { type GalaChainTokenClassKey, type GalaChainTokenInstanceKey } from '@gala-chain/gala-core-sdk';
|
|
8
|
+
import type { TokenId } from '../types/common';
|
|
9
9
|
/**
|
|
10
10
|
* Normalizes any token identifier format to TokenInstanceKey
|
|
11
11
|
*
|
|
@@ -39,31 +39,7 @@ import { isTokenClassKey as isTokenClassKeyStrict } from './token-parser';
|
|
|
39
39
|
* // → Same object returned
|
|
40
40
|
* ```
|
|
41
41
|
*/
|
|
42
|
-
export declare function normalizeToTokenInstanceKey(tokenId: TokenId):
|
|
43
|
-
/**
|
|
44
|
-
* Type guard to check if a TokenId is a TokenInstanceKey object
|
|
45
|
-
*
|
|
46
|
-
* @param tokenId Token identifier to check
|
|
47
|
-
* @returns True if tokenId is a TokenInstanceKey object
|
|
48
|
-
*/
|
|
49
|
-
export declare function isTokenInstanceKey(tokenId: TokenId): tokenId is TokenInstanceKey;
|
|
50
|
-
/**
|
|
51
|
-
* Strict type guard that validates all TokenClassKey fields are non-empty strings.
|
|
52
|
-
*
|
|
53
|
-
* Re-export of `isTokenClassKey` from `./token-parser` for convenience.
|
|
54
|
-
* This is the recommended function for validating TokenClassKey objects.
|
|
55
|
-
*
|
|
56
|
-
* @see isTokenClassKey from './token-parser' for the canonical implementation
|
|
57
|
-
* @since 6.6.1
|
|
58
|
-
*/
|
|
59
|
-
export { isTokenClassKeyStrict };
|
|
60
|
-
/**
|
|
61
|
-
* Type guard to check if a TokenId is a string
|
|
62
|
-
*
|
|
63
|
-
* @param tokenId Token identifier to check
|
|
64
|
-
* @returns True if tokenId is a string
|
|
65
|
-
*/
|
|
66
|
-
export declare function isTokenIdString(tokenId: TokenId): tokenId is string;
|
|
42
|
+
export declare function normalizeToTokenInstanceKey(tokenId: TokenId): GalaChainTokenInstanceKey;
|
|
67
43
|
/**
|
|
68
44
|
* Validates that a TokenId has all required fields
|
|
69
45
|
*
|
|
@@ -94,7 +70,7 @@ export declare function validateTokenId(tokenId: TokenId): void;
|
|
|
94
70
|
*
|
|
95
71
|
* @since 3.32.0
|
|
96
72
|
*/
|
|
97
|
-
export declare function parseVaultAddressToTokenClassKey(vaultAddress: string):
|
|
73
|
+
export declare function parseVaultAddressToTokenClassKey(vaultAddress: string): GalaChainTokenClassKey;
|
|
98
74
|
/**
|
|
99
75
|
* Parses a vault address into a TokenInstanceKey
|
|
100
76
|
*
|
|
@@ -115,7 +91,7 @@ export declare function parseVaultAddressToTokenClassKey(vaultAddress: string):
|
|
|
115
91
|
*
|
|
116
92
|
* @since 3.32.0
|
|
117
93
|
*/
|
|
118
|
-
export declare function parseVaultAddressToTokenInstance(vaultAddress: string):
|
|
94
|
+
export declare function parseVaultAddressToTokenInstance(vaultAddress: string): GalaChainTokenInstanceKey;
|
|
119
95
|
/**
|
|
120
96
|
* Extracts the launchpad token symbol (carried in `type` of the shared `Token` collection) from a
|
|
121
97
|
* launchpad vault address. Throws for any other collection: a symbol cannot be derived from a class key.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tokenNormalizer.d.ts","sourceRoot":"","sources":["../../src/utils/tokenNormalizer.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"tokenNormalizer.d.ts","sourceRoot":"","sources":["../../src/utils/tokenNormalizer.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAEL,KAAK,sBAAsB,EAC3B,KAAK,yBAAyB,EAC/B,MAAM,2BAA2B,CAAC;AAEnC,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAC;AAO/C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AACH,wBAAgB,2BAA2B,CAAC,OAAO,EAAE,OAAO,GAAG,yBAAyB,CAsEvF;AAED;;;;;GAKG;AACH,wBAAgB,eAAe,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,CActD;AAED;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wBAAgB,gCAAgC,CAAC,YAAY,EAAE,MAAM,GAAG,sBAAsB,CAG7F;AAED;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,gCAAgC,CAAC,YAAY,EAAE,MAAM,GAAG,yBAAyB,CAMhG;AAED;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAgB,2BAA2B,CAAC,YAAY,EAAE,MAAM,GAAG,MAAM,CAYxE;AAED;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,wBAAgB,wBAAwB,CAAC,OAAO,EAAE,OAAO,GAAG,MAAM,CAMjE"}
|
|
@@ -1,147 +1,20 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* The uniqueKey of a launchpad bundle trade (BundleService buy/sell).
|
|
3
3
|
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
* transfer and lock/unlock operations.
|
|
4
|
+
* A generic GalaChain uniqueKey is gala-core-sdk's `createUniqueKey(prefix)` (CSPRNG,
|
|
5
|
+
* `<prefix><uuid v4>`); launchpad-sdk 9.0 removed its own `generateUniqueKey`, which duplicated it.
|
|
7
6
|
*
|
|
8
7
|
* @category Utilities
|
|
9
8
|
* @since 6.14.0
|
|
10
9
|
*/
|
|
11
10
|
/**
|
|
12
|
-
* Generate a unique operation key for
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
* - Cryptographically random suffix (derived from a UUID v4, ~104 bits of entropy)
|
|
17
|
-
*
|
|
18
|
-
* Format: `galaconnect-operation-{timestamp}_{randomSuffix}`
|
|
19
|
-
*
|
|
20
|
-
* Used for idempotency across:
|
|
21
|
-
* - Token transfers (uniqueKey parameter)
|
|
22
|
-
* - Token locks/unlocks (uniqueKey parameter)
|
|
23
|
-
* - Token burns (uniqueKey parameter)
|
|
24
|
-
* - Any operation requiring request deduplication
|
|
25
|
-
*
|
|
26
|
-
* @returns Unique operation key in format `galaconnect-operation-{timestamp}_{randomSuffix}`
|
|
27
|
-
*
|
|
28
|
-
* @example Basic usage
|
|
29
|
-
* ```typescript
|
|
30
|
-
* import { generateUniqueKey } from '@gala-chain/launchpad-sdk';
|
|
31
|
-
*
|
|
32
|
-
* const key = generateUniqueKey();
|
|
33
|
-
* console.log(key); // 'galaconnect-operation-1735857234567_abc123'
|
|
34
|
-
*
|
|
35
|
-
* // Use in transfer operation
|
|
36
|
-
* await sdk.transferGala({
|
|
37
|
-
* recipientAddress: 'eth|0x...',
|
|
38
|
-
* amount: '100',
|
|
39
|
-
* uniqueKey: generateUniqueKey()
|
|
40
|
-
* });
|
|
41
|
-
* ```
|
|
42
|
-
*
|
|
43
|
-
* @example With explicit key
|
|
44
|
-
* ```typescript
|
|
45
|
-
* // For operations where you control the idempotency key
|
|
46
|
-
* const operationKey = `my-operation-${Date.now()}`;
|
|
47
|
-
* await sdk.transferToken({
|
|
48
|
-
* to: 'eth|0x...',
|
|
49
|
-
* tokenName: 'anime',
|
|
50
|
-
* amount: '1000',
|
|
51
|
-
* uniqueKey: operationKey
|
|
52
|
-
* });
|
|
53
|
-
* ```
|
|
54
|
-
*
|
|
55
|
-
* @see {@link https://docs.galachain.com/idempotency GalaChain Idempotency}
|
|
56
|
-
*/
|
|
57
|
-
export declare function generateUniqueKey(): string;
|
|
58
|
-
/**
|
|
59
|
-
* Generate a unique operation key for GalaSwap bundle (buy/sell) transactions.
|
|
60
|
-
*
|
|
61
|
-
* Same shape and entropy guarantees as {@link generateUniqueKey}, but uses the
|
|
62
|
-
* `galaswap-operation-` prefix GalaSwap trade operations are identified by
|
|
63
|
-
* (`UNIQUE_KEY_CONSTRAINT.PATTERN` accepts either prefix).
|
|
11
|
+
* Generate a unique operation key for GalaSwap bundle (buy/sell) transactions:
|
|
12
|
+
* `galaswap-operation-{timestamp}_{randomSuffix}`, the suffix 26 hex digits of a UUID v4
|
|
13
|
+
* (~104 bits; never `Math.random()`: a collision would let GalaChain treat two different trades as
|
|
14
|
+
* retries of one), within `UNIQUE_KEY_CONSTRAINT.MAX_LENGTH` (64) and its `PATTERN`.
|
|
64
15
|
*
|
|
65
16
|
* @returns Unique operation key in format `galaswap-operation-{timestamp}_{randomSuffix}`
|
|
66
17
|
* @since 6.14.0
|
|
67
18
|
*/
|
|
68
19
|
export declare function generateSwapOperationKey(): string;
|
|
69
|
-
/**
|
|
70
|
-
* Generate unique operation key with UUID, timestamp, and wallet address
|
|
71
|
-
*
|
|
72
|
-
* Creates a unique identifier for GalaSwap operations combining:
|
|
73
|
-
* - Prefix (customizable, defaults to 'galaswap-operation')
|
|
74
|
-
* - UUID v4 for global uniqueness
|
|
75
|
-
* - Timestamp (millisecond precision)
|
|
76
|
-
* - Wallet address for context
|
|
77
|
-
*
|
|
78
|
-
* Format: `{prefix}-${uuid}-${timestamp}-${walletAddress}`
|
|
79
|
-
*
|
|
80
|
-
* Used for idempotent GalaSwap operations including:
|
|
81
|
-
* - Liquidity additions (add/remove)
|
|
82
|
-
* - Swap executions
|
|
83
|
-
* - Fee collections
|
|
84
|
-
* - Bundle transactions
|
|
85
|
-
*
|
|
86
|
-
* @param walletAddress The wallet address associated with the operation (required)
|
|
87
|
-
* @param prefix Optional custom prefix (defaults to 'galaswap-operation')
|
|
88
|
-
* @returns Unique operation key combining UUID, timestamp, and wallet address
|
|
89
|
-
*
|
|
90
|
-
* @example Basic usage with default prefix
|
|
91
|
-
* ```typescript
|
|
92
|
-
* import { generateOperationKey } from '@gala-chain/launchpad-sdk';
|
|
93
|
-
*
|
|
94
|
-
* const operationKey = generateOperationKey('eth|0x1234567890abcdef...');
|
|
95
|
-
* console.log(operationKey);
|
|
96
|
-
* // 'galaswap-operation-550e8400-e29b-41d4-a716-446655440000-1735857234567-eth|0x1234...'
|
|
97
|
-
* ```
|
|
98
|
-
*
|
|
99
|
-
* @example With custom prefix
|
|
100
|
-
* ```typescript
|
|
101
|
-
* import { generateOperationKey } from '@gala-chain/launchpad-sdk';
|
|
102
|
-
*
|
|
103
|
-
* const operationKey = generateOperationKey(
|
|
104
|
-
* 'eth|0x1234567890abcdef...',
|
|
105
|
-
* 'custom-swap'
|
|
106
|
-
* );
|
|
107
|
-
* console.log(operationKey);
|
|
108
|
-
* // 'custom-swap-550e8400-e29b-41d4-a716-446655440000-1735857234567-eth|0x1234...'
|
|
109
|
-
* ```
|
|
110
|
-
*
|
|
111
|
-
* @example With an operation that accepts a caller-supplied uniqueKey
|
|
112
|
-
* ```typescript
|
|
113
|
-
* import { generateOperationKey } from '@gala-chain/launchpad-sdk';
|
|
114
|
-
*
|
|
115
|
-
* // transferGala/transferToken/lockToken/unlockToken accept an optional
|
|
116
|
-
* // uniqueKey for idempotency (sdk.dex.* writes generate their own internally).
|
|
117
|
-
* const result = await sdk.transferGala({
|
|
118
|
-
* recipientAddress,
|
|
119
|
-
* amount: '100',
|
|
120
|
-
* uniqueKey: generateOperationKey(walletAddress),
|
|
121
|
-
* });
|
|
122
|
-
* ```
|
|
123
|
-
*
|
|
124
|
-
* @example Handling operation idempotency
|
|
125
|
-
* ```typescript
|
|
126
|
-
* // sdk.dex.swaps.swap() generates its own durable uniqueKey and returns it on the
|
|
127
|
-
* // SubmittedTransaction, so recovering an in-flight swap replays confirmation instead
|
|
128
|
-
* // of resubmitting with a caller-supplied key:
|
|
129
|
-
* let submitted;
|
|
130
|
-
* try {
|
|
131
|
-
* submitted = await sdk.dex.swaps.swap('GALA', 'GUSDC', 3000, {
|
|
132
|
-
* exactIn: '100',
|
|
133
|
-
* amountOutMinimum: '95',
|
|
134
|
-
* });
|
|
135
|
-
* await submitted.confirm();
|
|
136
|
-
* } catch (error) {
|
|
137
|
-
* if (submitted) {
|
|
138
|
-
* // Recover by uniqueKey - does not resubmit, avoids duplicate execution
|
|
139
|
-
* await sdk.dex.swaps.confirmSwap(submitted.uniqueKey);
|
|
140
|
-
* }
|
|
141
|
-
* }
|
|
142
|
-
* ```
|
|
143
|
-
*
|
|
144
|
-
* @since 3.50.0
|
|
145
|
-
*/
|
|
146
|
-
export declare function generateOperationKey(walletAddress: string, prefix?: string): string;
|
|
147
20
|
//# sourceMappingURL=unique-key-generator.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"unique-key-generator.d.ts","sourceRoot":"","sources":["../../src/utils/unique-key-generator.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"unique-key-generator.d.ts","sourceRoot":"","sources":["../../src/utils/unique-key-generator.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAIH;;;;;;;;GAQG;AACH,wBAAgB,wBAAwB,IAAI,MAAM,CAIjD"}
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
* @category Utilities
|
|
8
8
|
* @since 3.6.2
|
|
9
9
|
*/
|
|
10
|
-
import {
|
|
10
|
+
import type { TokenNameConstraint } from '../types/constraints';
|
|
11
11
|
import { isEmptyValue as isEmptyValuePrimitive, isNonEmptyString as isNonEmptyStringPrimitive, isNullish as isNullishPrimitive } from './primitives';
|
|
12
12
|
/**
|
|
13
13
|
* Pagination bounds structure (required fields)
|
|
@@ -275,10 +275,8 @@ export interface MutualExclusivityResult {
|
|
|
275
275
|
/**
|
|
276
276
|
* Validates that exactly one of two parameters is provided (mutual exclusivity)
|
|
277
277
|
*
|
|
278
|
-
* Consolidates
|
|
279
|
-
*
|
|
280
|
-
* - DexService: Similar patterns with token identification
|
|
281
|
-
* - Other services: Scattered mutual exclusivity validation
|
|
278
|
+
* Consolidates the mutual-exclusivity checks the services used to repeat (e.g. tokenName XOR
|
|
279
|
+
* tokenId for a token identification).
|
|
282
280
|
*
|
|
283
281
|
* ## Use Cases
|
|
284
282
|
*
|
|
@@ -322,7 +320,7 @@ export interface MutualExclusivityResult {
|
|
|
322
320
|
*
|
|
323
321
|
* @example Token identifier validation
|
|
324
322
|
* ```typescript
|
|
325
|
-
* //
|
|
323
|
+
* // a method that takes a token by name or by id, never both
|
|
326
324
|
* const { hasA } = validateMutualExclusive(options, 'tokenName', 'tokenId', {
|
|
327
325
|
* description: 'token identifier'
|
|
328
326
|
* });
|
|
@@ -338,89 +336,48 @@ export declare function validateMutualExclusive(obj: Record<string, unknown>, fi
|
|
|
338
336
|
}): MutualExclusivityResult;
|
|
339
337
|
export type { TokenNameConstraint };
|
|
340
338
|
/**
|
|
341
|
-
* Validates a launchpad token name
|
|
339
|
+
* Validates a launchpad token name against the rule of the route it is sent to
|
|
342
340
|
*
|
|
343
|
-
*
|
|
344
|
-
*
|
|
345
|
-
* - content-flag.dto.ts (validateFlagTokenName)
|
|
346
|
-
* - comment.dto.ts (inline validation)
|
|
347
|
-
* - ban.dto.ts (inline validation)
|
|
348
|
-
* - moderator.dto.ts (inline validation)
|
|
341
|
+
* There is no default constraint: the rule is the backend route's (`TOKEN_NAME_DTO_CONSTRAINT`,
|
|
342
|
+
* `TOKEN_NAME_PATH_CONSTRAINT`, ... in `types/constraints`), so the caller names it.
|
|
349
343
|
*
|
|
350
|
-
* ## Usage
|
|
351
|
-
*
|
|
352
|
-
* ### With default constraints (3-20 alphanumeric)
|
|
353
|
-
* ```typescript
|
|
354
|
-
* validateLaunchpadTokenName(tokenName); // Uses LAUNCHPAD_TOKEN_NAME_CONSTRAINT
|
|
355
|
-
* ```
|
|
356
|
-
*
|
|
357
|
-
* ### With custom constraints from DTO
|
|
358
344
|
* ```typescript
|
|
359
|
-
*
|
|
360
|
-
* validateLaunchpadTokenName(tokenName, 'tokenName', STREAMING_CONSTRAINTS.TOKEN_NAME);
|
|
361
|
-
* ```
|
|
362
|
-
*
|
|
363
|
-
* ### With custom field name for error messages
|
|
364
|
-
* ```typescript
|
|
365
|
-
* validateLaunchpadTokenName(options.tokenName, 'tokenName', BAN_CONSTRAINTS.TOKEN_NAME);
|
|
345
|
+
* validateLaunchpadTokenName(options.tokenName, 'tokenName', TOKEN_NAME_DTO_CONSTRAINT);
|
|
366
346
|
* ```
|
|
367
347
|
*
|
|
368
348
|
* @param tokenName - Token name to validate
|
|
369
|
-
* @param field - Field name for error messages
|
|
370
|
-
* @param constraint -
|
|
349
|
+
* @param field - Field name for error messages
|
|
350
|
+
* @param constraint - The route's token name constraint
|
|
371
351
|
* @throws {ValidationError} If token name is invalid (empty, too short, too long, or invalid format)
|
|
372
352
|
*
|
|
373
353
|
* @since 6.4.0
|
|
374
354
|
*/
|
|
375
|
-
export declare function validateLaunchpadTokenName(tokenName: string, field
|
|
355
|
+
export declare function validateLaunchpadTokenName(tokenName: string, field: string, constraint: TokenNameConstraint): void;
|
|
376
356
|
/**
|
|
377
357
|
* Validates an optional token name (allows undefined/null, but validates if present)
|
|
378
358
|
*
|
|
379
359
|
* Use this for optional token name fields that should be validated when provided.
|
|
380
|
-
* Consolidates duplicate logic from tokenNameValidator.ts.
|
|
381
360
|
*
|
|
382
361
|
* @param tokenName - The token name to validate (may be undefined/null)
|
|
383
|
-
* @param field - The field name for error messages
|
|
384
|
-
* @param constraint -
|
|
362
|
+
* @param field - The field name for error messages
|
|
363
|
+
* @param constraint - The route's token name constraint
|
|
385
364
|
* @throws {ValidationError} If token name is provided but invalid
|
|
386
365
|
*
|
|
387
|
-
* @example
|
|
388
|
-
* ```typescript
|
|
389
|
-
* // No error - undefined is allowed
|
|
390
|
-
* validateOptionalTokenName(undefined);
|
|
391
|
-
*
|
|
392
|
-
* // Throws ValidationError - provided but invalid
|
|
393
|
-
* validateOptionalTokenName('ab');
|
|
394
|
-
*
|
|
395
|
-
* // Success - valid token name
|
|
396
|
-
* validateOptionalTokenName('myToken123');
|
|
397
|
-
* ```
|
|
398
|
-
*
|
|
399
366
|
* @since 6.12.0
|
|
400
367
|
*/
|
|
401
|
-
export declare function validateOptionalTokenName(tokenName: unknown, field
|
|
368
|
+
export declare function validateOptionalTokenName(tokenName: unknown, field: string, constraint: TokenNameConstraint): void;
|
|
402
369
|
/**
|
|
403
370
|
* Checks if a token name is valid without throwing
|
|
404
371
|
*
|
|
405
372
|
* Use this for conditional checks where you don't want exceptions.
|
|
406
|
-
* Consolidates duplicate logic from tokenNameValidator.ts.
|
|
407
373
|
*
|
|
408
374
|
* @param tokenName - The token name to check
|
|
409
|
-
* @param constraint -
|
|
375
|
+
* @param constraint - The route's token name constraint
|
|
410
376
|
* @returns true if valid, false otherwise
|
|
411
377
|
*
|
|
412
|
-
* @example
|
|
413
|
-
* ```typescript
|
|
414
|
-
* if (isValidTokenName(userInput)) {
|
|
415
|
-
* // Proceed with token lookup
|
|
416
|
-
* } else {
|
|
417
|
-
* // Show validation error to user
|
|
418
|
-
* }
|
|
419
|
-
* ```
|
|
420
|
-
*
|
|
421
378
|
* @since 6.12.0
|
|
422
379
|
*/
|
|
423
|
-
export declare function isValidTokenName(tokenName: unknown, constraint
|
|
380
|
+
export declare function isValidTokenName(tokenName: unknown, constraint: TokenNameConstraint): tokenName is string;
|
|
424
381
|
/**
|
|
425
382
|
* Validates a token name with constraint-specific error messages
|
|
426
383
|
*
|
|
@@ -428,19 +385,19 @@ export declare function isValidTokenName(tokenName: unknown, constraint?: TokenN
|
|
|
428
385
|
* This is the recommended function for service methods.
|
|
429
386
|
*
|
|
430
387
|
* @param tokenName - Token name to validate
|
|
431
|
-
* @param field - Field name for error messages
|
|
432
|
-
* @param constraint -
|
|
388
|
+
* @param field - Field name for error messages
|
|
389
|
+
* @param constraint - The route's token name constraint
|
|
433
390
|
* @throws {ValidationError} If token name is invalid
|
|
434
391
|
*
|
|
435
392
|
* @example
|
|
436
393
|
* ```typescript
|
|
437
|
-
* // Throws: "tokenName must be
|
|
438
|
-
* validateTokenName('
|
|
394
|
+
* // Throws: "tokenName must be 1-20 letters and digits"
|
|
395
|
+
* validateTokenName('my-token', 'tokenName', TOKEN_NAME_DTO_CONSTRAINT);
|
|
439
396
|
* ```
|
|
440
397
|
*
|
|
441
398
|
* @since 6.12.0
|
|
442
399
|
*/
|
|
443
|
-
export declare function validateTokenName(tokenName: unknown, field
|
|
400
|
+
export declare function validateTokenName(tokenName: unknown, field: string, constraint: TokenNameConstraint): void;
|
|
444
401
|
/**
|
|
445
402
|
* Field validator configuration for structural type guards
|
|
446
403
|
*
|