@gala-chain/launchpad-sdk 8.1.0 → 9.0.0-rc.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +362 -0
- package/EXAMPLES.md +95 -681
- package/MIGRATING-TO-9.0.md +301 -0
- package/README.md +46 -17
- package/dist/LaunchpadSDK.d.ts +138 -413
- package/dist/LaunchpadSDK.d.ts.map +1 -1
- package/dist/api/LaunchpadAPI.d.ts +5 -37
- package/dist/api/LaunchpadAPI.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/types.d.ts +1 -1
- 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 +0 -7
- package/dist/constants/endpoints.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/helpers/sdk.d.ts.map +1 -1
- package/dist/index.browser.d.ts +8 -22
- 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 +1 -9
- package/dist/launchpad/bundle-submission.d.ts.map +1 -1
- package/dist/launchpad/transport.d.ts +2 -1
- package/dist/launchpad/transport.d.ts.map +1 -1
- package/dist/native.cjs +1 -1
- package/dist/native.d.ts +3 -4
- package/dist/native.d.ts.map +1 -1
- package/dist/native.esm.js +1 -1
- package/dist/schemas/user.d.ts +0 -15
- package/dist/schemas/user.d.ts.map +1 -1
- package/dist/services/AbstractCacheService.d.ts +2 -2
- 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/LaunchpadPriceService.d.ts +66 -0
- package/dist/services/LaunchpadPriceService.d.ts.map +1 -0
- package/dist/services/NftCollectionService.d.ts +22 -6
- package/dist/services/NftCollectionService.d.ts.map +1 -1
- package/dist/services/TokenResolverService.d.ts +5 -5
- package/dist/services/TokenResolverService.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/signing/index.d.ts +2 -3
- package/dist/signing/index.d.ts.map +1 -1
- package/dist/signing/signers.d.ts +7 -8
- 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/burn.dto.d.ts +4 -2
- package/dist/types/burn.dto.d.ts.map +1 -1
- package/dist/types/common.d.ts +2 -23
- package/dist/types/common.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/launchpad.dto.d.ts +0 -257
- 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/options.dto.d.ts +8 -34
- package/dist/types/options.dto.d.ts.map +1 -1
- package/dist/types/user.dto.d.ts +7 -62
- package/dist/types/user.dto.d.ts.map +1 -1
- package/dist/utils/address-formatter.d.ts +10 -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 +6 -239
- 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-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 +0 -308
- package/dist/utils/errors.d.ts.map +1 -1
- package/dist/utils/http.d.ts +15 -3
- package/dist/utils/http.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 +3 -5
- package/dist/utils/validation-helpers.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/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/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/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
|
@@ -63,53 +63,6 @@
|
|
|
63
63
|
* @since 6.17.0
|
|
64
64
|
*/
|
|
65
65
|
export declare function extractErrorMessageFromUnknown(error: unknown): string;
|
|
66
|
-
/**
|
|
67
|
-
* Generic GSwap error handler with fallback message
|
|
68
|
-
*
|
|
69
|
-
* Consolidates 18 occurrences of pattern:
|
|
70
|
-
* `if (isAxiosError) { extract status } else { generic message }`.
|
|
71
|
-
*
|
|
72
|
-
* Provides consistent error handling across GSwap service operations.
|
|
73
|
-
*
|
|
74
|
-
* @param error Unknown error from GSwap operation
|
|
75
|
-
* @param context Operation context for error message (e.g., "quote generation")
|
|
76
|
-
* @returns Error with context-prefixed message, preserving original error if HTTP error
|
|
77
|
-
*
|
|
78
|
-
* @example GSwap quote error
|
|
79
|
-
* ```typescript
|
|
80
|
-
* try {
|
|
81
|
-
* const quote = await gswapClient.getQuote(params);
|
|
82
|
-
* } catch (error: unknown) {
|
|
83
|
-
* throw handleGSwapErrorGeneric(error, 'quote generation');
|
|
84
|
-
* // Throws: Error("GSwap quote generation failed: ...")
|
|
85
|
-
* }
|
|
86
|
-
* ```
|
|
87
|
-
*
|
|
88
|
-
* @example GSwap pool error
|
|
89
|
-
* ```typescript
|
|
90
|
-
* try {
|
|
91
|
-
* const pools = await gswapClient.pools.getPools();
|
|
92
|
-
* } catch (error: unknown) {
|
|
93
|
-
* throw handleGSwapErrorGeneric(error, 'pool info retrieval');
|
|
94
|
-
* // Throws: Error("GSwap pool info retrieval failed: ...")
|
|
95
|
-
* }
|
|
96
|
-
* ```
|
|
97
|
-
*
|
|
98
|
-
* @example HTTP error with status code
|
|
99
|
-
* ```typescript
|
|
100
|
-
* try {
|
|
101
|
-
* const submitted = await gswapClient.swaps.swap(tokenIn, tokenOut, fee, swapAmount);
|
|
102
|
-
* await submitted.confirm();
|
|
103
|
-
* } catch (error: unknown) {
|
|
104
|
-
* const err = handleGSwapErrorGeneric(error, 'swap execution');
|
|
105
|
-
* // If HTTP error (404): Error with additional context
|
|
106
|
-
* // If network error: Generic error with message
|
|
107
|
-
* }
|
|
108
|
-
* ```
|
|
109
|
-
*
|
|
110
|
-
* @since 6.17.0
|
|
111
|
-
*/
|
|
112
|
-
export declare function handleGSwapErrorGeneric(error: unknown, context: string): Error;
|
|
113
66
|
/**
|
|
114
67
|
* Log error with full stack trace and context
|
|
115
68
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"error-patterns.d.ts","sourceRoot":"","sources":["../../src/utils/error-patterns.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;
|
|
1
|
+
{"version":3,"file":"error-patterns.d.ts","sourceRoot":"","sources":["../../src/utils/error-patterns.ts"],"names":[],"mapp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';
|
|
|
116
116
|
*
|
|
117
117
|
* @example With custom error handler
|
|
118
118
|
* ```typescript
|
|
119
|
-
* async
|
|
119
|
+
* async fetchQuote(params: QuoteParams): Promise<QuoteResult> {
|
|
120
120
|
* return withErrorHandling(
|
|
121
|
-
* () => this.
|
|
122
|
-
* 'Failed to get
|
|
121
|
+
* () => this.quoteService.quote(params),
|
|
122
|
+
* 'Failed to get quote',
|
|
123
123
|
* this.logger,
|
|
124
124
|
* (error, context, logger) => {
|
|
125
|
-
* // Custom error handling
|
|
126
|
-
* throw new
|
|
125
|
+
* // Custom error handling (the wrapper already logs)
|
|
126
|
+
* throw new NetworkError(`${context}: ${getErrorMessage(error)}`);
|
|
127
127
|
* }
|
|
128
128
|
* );
|
|
129
129
|
* }
|
package/dist/utils/errors.d.ts
CHANGED
|
@@ -242,312 +242,4 @@ export declare class TransactionError extends Error {
|
|
|
242
242
|
*/
|
|
243
243
|
constructor(message: string, transactionId?: string | undefined, code?: string | undefined);
|
|
244
244
|
}
|
|
245
|
-
/**
|
|
246
|
-
* Error thrown when GSwap SDK quote operations fail
|
|
247
|
-
*
|
|
248
|
-
* This error is thrown during quote generation (exact input or exact output).
|
|
249
|
-
* It preserves the original GSwap SDK error for detailed diagnostics.
|
|
250
|
-
*
|
|
251
|
-
* @example Quote generation failure
|
|
252
|
-
* ```typescript
|
|
253
|
-
* throw new GSwapQuoteError(
|
|
254
|
-
* 'Failed to get quote for GALA to GUSDC swap',
|
|
255
|
-
* originalGSwapError,
|
|
256
|
-
* 'POOL_NOT_FOUND'
|
|
257
|
-
* );
|
|
258
|
-
* ```
|
|
259
|
-
*
|
|
260
|
-
* @example Catching quote errors
|
|
261
|
-
* ```typescript
|
|
262
|
-
* try {
|
|
263
|
-
* const quote = await sdk.dex.quoting.quoteExactInput('GALA', 'GUSDC', '100');
|
|
264
|
-
* } catch (error) {
|
|
265
|
-
* if (error instanceof GSwapQuoteError) {
|
|
266
|
-
* console.log(`Quote failed: ${error.message}`);
|
|
267
|
-
* console.log(`GSwap error: ${error.code}`);
|
|
268
|
-
* // Implement user notification
|
|
269
|
-
* }
|
|
270
|
-
* }
|
|
271
|
-
* ```
|
|
272
|
-
*/
|
|
273
|
-
export declare class GSwapQuoteError extends Error {
|
|
274
|
-
originalError: unknown;
|
|
275
|
-
code?: string | undefined;
|
|
276
|
-
/**
|
|
277
|
-
* Creates a new GSwapQuoteError
|
|
278
|
-
*
|
|
279
|
-
* @param message - Human-readable error message describing what failed
|
|
280
|
-
* @param originalError - The original error from GSwap SDK
|
|
281
|
-
* @param code - Optional error code from GSwap SDK for programmatic handling
|
|
282
|
-
*/
|
|
283
|
-
constructor(message: string, originalError: unknown, code?: string | undefined);
|
|
284
|
-
}
|
|
285
|
-
/**
|
|
286
|
-
* Error thrown when GSwap SDK swap execution fails
|
|
287
|
-
*
|
|
288
|
-
* This error is thrown during token swap execution (buy/sell operations).
|
|
289
|
-
* It preserves the original GSwap SDK error and transaction details.
|
|
290
|
-
*
|
|
291
|
-
* @example Swap execution failure
|
|
292
|
-
* ```typescript
|
|
293
|
-
* throw new GSwapSwapError(
|
|
294
|
-
* 'Token swap failed: insufficient balance',
|
|
295
|
-
* originalGSwapError,
|
|
296
|
-
* 'txHash123',
|
|
297
|
-
* 'INSUFFICIENT_BALANCE'
|
|
298
|
-
* );
|
|
299
|
-
* ```
|
|
300
|
-
*
|
|
301
|
-
* @example Catching swap errors
|
|
302
|
-
* ```typescript
|
|
303
|
-
* try {
|
|
304
|
-
* const submitted = await sdk.dex.swaps.swap(tokenIn, tokenOut, fee, swapAmount);
|
|
305
|
-
* const result = await submitted.confirm();
|
|
306
|
-
* } catch (error) {
|
|
307
|
-
* if (error instanceof GSwapSwapError) {
|
|
308
|
-
* console.log(`Swap failed: ${error.message}`);
|
|
309
|
-
* if (error.transactionHash) {
|
|
310
|
-
* console.log(`TX: ${error.transactionHash}`);
|
|
311
|
-
* }
|
|
312
|
-
* }
|
|
313
|
-
* }
|
|
314
|
-
* ```
|
|
315
|
-
*/
|
|
316
|
-
export declare class GSwapSwapError extends Error {
|
|
317
|
-
originalError: unknown;
|
|
318
|
-
transactionHash?: string | undefined;
|
|
319
|
-
code?: string | undefined;
|
|
320
|
-
/**
|
|
321
|
-
* Creates a new GSwapSwapError
|
|
322
|
-
*
|
|
323
|
-
* @param message - Human-readable error message describing what failed
|
|
324
|
-
* @param originalError - The original error from GSwap SDK
|
|
325
|
-
* @param transactionHash - Optional transaction hash for transaction tracking
|
|
326
|
-
* @param code - Optional error code from GSwap SDK for programmatic handling
|
|
327
|
-
*/
|
|
328
|
-
constructor(message: string, originalError: unknown, transactionHash?: string | undefined, code?: string | undefined);
|
|
329
|
-
}
|
|
330
|
-
/**
|
|
331
|
-
* Error thrown when GSwap SDK pool operations fail
|
|
332
|
-
*
|
|
333
|
-
* This error is thrown when pool-related queries fail, including:
|
|
334
|
-
* - Pool information retrieval
|
|
335
|
-
* - Available token swaps querying
|
|
336
|
-
* - Pool data access errors
|
|
337
|
-
*
|
|
338
|
-
* @example Pool query failure
|
|
339
|
-
* ```typescript
|
|
340
|
-
* throw new GSwapPoolError(
|
|
341
|
-
* 'Pool not found for GALA/GUSDC pair',
|
|
342
|
-
* originalGSwapError,
|
|
343
|
-
* 'GALA',
|
|
344
|
-
* 'GUSDC',
|
|
345
|
-
* 'POOL_NOT_FOUND'
|
|
346
|
-
* );
|
|
347
|
-
* ```
|
|
348
|
-
*
|
|
349
|
-
* @example Catching pool errors
|
|
350
|
-
* ```typescript
|
|
351
|
-
* try {
|
|
352
|
-
* const poolInfo = await service.getPoolInfo('GALA', 'GUSDC');
|
|
353
|
-
* } catch (error) {
|
|
354
|
-
* if (error instanceof GSwapPoolError) {
|
|
355
|
-
* console.log(`Pool error: ${error.message}`);
|
|
356
|
-
* if (error.code === 'POOL_NOT_FOUND') {
|
|
357
|
-
* console.log(`No pool for ${error.tokenA}/${error.tokenB}`);
|
|
358
|
-
* }
|
|
359
|
-
* }
|
|
360
|
-
* }
|
|
361
|
-
* ```
|
|
362
|
-
*/
|
|
363
|
-
export declare class GSwapPoolError extends Error {
|
|
364
|
-
originalError: unknown;
|
|
365
|
-
tokenA?: string | undefined;
|
|
366
|
-
tokenB?: string | undefined;
|
|
367
|
-
code?: string | undefined;
|
|
368
|
-
/**
|
|
369
|
-
* Creates a new GSwapPoolError
|
|
370
|
-
*
|
|
371
|
-
* @param message - Human-readable error message describing what failed
|
|
372
|
-
* @param originalError - The original error from GSwap SDK
|
|
373
|
-
* @param tokenA - Optional token A symbol in the pool pair
|
|
374
|
-
* @param tokenB - Optional token B symbol in the pool pair
|
|
375
|
-
* @param code - Optional error code from GSwap SDK for programmatic handling
|
|
376
|
-
*/
|
|
377
|
-
constructor(message: string, originalError: unknown, tokenA?: string | undefined, tokenB?: string | undefined, code?: string | undefined);
|
|
378
|
-
}
|
|
379
|
-
/**
|
|
380
|
-
* Error thrown when GSwap SDK asset/balance operations fail
|
|
381
|
-
*
|
|
382
|
-
* This error is thrown when asset-related queries fail, including:
|
|
383
|
-
* - User asset/balance retrieval
|
|
384
|
-
* - Portfolio data access errors
|
|
385
|
-
* - Asset validation failures
|
|
386
|
-
*
|
|
387
|
-
* @example Asset query failure
|
|
388
|
-
* ```typescript
|
|
389
|
-
* throw new GSwapAssetError(
|
|
390
|
-
* 'Failed to fetch user assets',
|
|
391
|
-
* originalGSwapError,
|
|
392
|
-
* 'userAddress123',
|
|
393
|
-
* 'NETWORK_ERROR'
|
|
394
|
-
* );
|
|
395
|
-
* ```
|
|
396
|
-
*
|
|
397
|
-
* @example Catching asset errors
|
|
398
|
-
* ```typescript
|
|
399
|
-
* try {
|
|
400
|
-
* const assets = await service.getUserAssets(walletAddress);
|
|
401
|
-
* } catch (error) {
|
|
402
|
-
* if (error instanceof GSwapAssetError) {
|
|
403
|
-
* console.log(`Asset query failed: ${error.message}`);
|
|
404
|
-
* console.log(`Wallet: ${error.walletAddress}`);
|
|
405
|
-
* }
|
|
406
|
-
* }
|
|
407
|
-
* ```
|
|
408
|
-
*/
|
|
409
|
-
export declare class GSwapAssetError extends Error {
|
|
410
|
-
originalError: unknown;
|
|
411
|
-
walletAddress?: string | undefined;
|
|
412
|
-
code?: string | undefined;
|
|
413
|
-
/**
|
|
414
|
-
* Creates a new GSwapAssetError
|
|
415
|
-
*
|
|
416
|
-
* @param message - Human-readable error message describing what failed
|
|
417
|
-
* @param originalError - The original error from GSwap SDK
|
|
418
|
-
* @param walletAddress - Optional wallet address being queried
|
|
419
|
-
* @param code - Optional error code from GSwap SDK for programmatic handling
|
|
420
|
-
*/
|
|
421
|
-
constructor(message: string, originalError: unknown, walletAddress?: string | undefined, code?: string | undefined);
|
|
422
|
-
}
|
|
423
|
-
/**
|
|
424
|
-
* Error thrown when GSwap SDK liquidity position operations fail
|
|
425
|
-
*
|
|
426
|
-
* This error is thrown when position management operations fail, including:
|
|
427
|
-
* - Position queries (getUserPositions, getPosition, getPositionById)
|
|
428
|
-
* - Liquidity addition (addLiquidityByPrice, addLiquidityByTicks)
|
|
429
|
-
* - Liquidity removal (removeLiquidity)
|
|
430
|
-
* - Fee collection (collectPositionFees)
|
|
431
|
-
* - Position estimation (estimateRemoveLiquidity)
|
|
432
|
-
*
|
|
433
|
-
* @example Position operation failure
|
|
434
|
-
* ```typescript
|
|
435
|
-
* throw new GSwapPositionError(
|
|
436
|
-
* 'Failed to add liquidity to GALA/GUSDC pool',
|
|
437
|
-
* originalGSwapError,
|
|
438
|
-
* 'INSUFFICIENT_BALANCE'
|
|
439
|
-
* );
|
|
440
|
-
* ```
|
|
441
|
-
*
|
|
442
|
-
* @example Catching position errors
|
|
443
|
-
* ```typescript
|
|
444
|
-
* try {
|
|
445
|
-
* const result = await service.addLiquidityByPrice({ token0: 'GALA', token1: 'GUSDC', ... });
|
|
446
|
-
* } catch (error) {
|
|
447
|
-
* if (error instanceof GSwapPositionError) {
|
|
448
|
-
* console.log(`Position operation failed: ${error.message}`);
|
|
449
|
-
* console.log(`Error code: ${error.code}`);
|
|
450
|
-
* // Implement user notification or recovery logic
|
|
451
|
-
* }
|
|
452
|
-
* }
|
|
453
|
-
* ```
|
|
454
|
-
*/
|
|
455
|
-
export declare class GSwapPositionError extends Error {
|
|
456
|
-
originalError: unknown;
|
|
457
|
-
code?: string | undefined;
|
|
458
|
-
/**
|
|
459
|
-
* Creates a new GSwapPositionError
|
|
460
|
-
*
|
|
461
|
-
* @param message - Human-readable error message describing what failed
|
|
462
|
-
* @param originalError - The original error from GSwap SDK
|
|
463
|
-
* @param code - Optional error code from GSwap SDK for programmatic handling
|
|
464
|
-
*/
|
|
465
|
-
constructor(message: string, originalError: unknown, code?: string | undefined);
|
|
466
|
-
}
|
|
467
|
-
/**
|
|
468
|
-
* Error thrown when DEX quote operations fail
|
|
469
|
-
*
|
|
470
|
-
* This error is thrown during DEX quote calculations (local and external),
|
|
471
|
-
* composite pool data fetching, and related operations. It captures the
|
|
472
|
-
* operation context for debugging and recovery.
|
|
473
|
-
*
|
|
474
|
-
* @example Quote calculation failure
|
|
475
|
-
* ```typescript
|
|
476
|
-
* throw new DexQuoteError(
|
|
477
|
-
* 'Failed to calculate quote for GALA/BENE swap',
|
|
478
|
-
* {
|
|
479
|
-
* fromToken: 'GALA|Unit|none|none',
|
|
480
|
-
* toToken: 'Token|Unit|BENE|client:123',
|
|
481
|
-
* amount: '1000'
|
|
482
|
-
* }
|
|
483
|
-
* );
|
|
484
|
-
* ```
|
|
485
|
-
*
|
|
486
|
-
* @example Catching quote errors
|
|
487
|
-
* ```typescript
|
|
488
|
-
* try {
|
|
489
|
-
* const quote = await sdk.calculateDexPoolQuoteExactAmountLocal({
|
|
490
|
-
* compositePoolData: composite,
|
|
491
|
-
* fromToken: 'GALA|Unit|none|none',
|
|
492
|
-
* toToken: 'Token|Unit|BENE|client:123',
|
|
493
|
-
* amount: '1000'
|
|
494
|
-
* });
|
|
495
|
-
* } catch (error) {
|
|
496
|
-
* if (error instanceof DexQuoteError) {
|
|
497
|
-
* console.log(`Quote failed: ${error.message}`);
|
|
498
|
-
* if (error.context) {
|
|
499
|
-
* console.log(`Tokens: ${error.context.fromToken} → ${error.context.toToken}`);
|
|
500
|
-
* }
|
|
501
|
-
* }
|
|
502
|
-
* }
|
|
503
|
-
* ```
|
|
504
|
-
*/
|
|
505
|
-
export declare class DexQuoteError extends ValidationError {
|
|
506
|
-
context?: unknown | undefined;
|
|
507
|
-
/**
|
|
508
|
-
* Creates a new DexQuoteError
|
|
509
|
-
*
|
|
510
|
-
* @param message - Human-readable error message describing what failed
|
|
511
|
-
* @param context - Optional context object with operation details (tokens, amounts, etc.)
|
|
512
|
-
*/
|
|
513
|
-
constructor(message: string, context?: unknown | undefined);
|
|
514
|
-
}
|
|
515
|
-
/**
|
|
516
|
-
* Error thrown when a DEX pool is not found
|
|
517
|
-
*
|
|
518
|
-
* This error is thrown when attempting to access or fetch data for a DEX pool
|
|
519
|
-
* that does not exist, typically during composite pool data retrieval or pool
|
|
520
|
-
* discovery operations.
|
|
521
|
-
*
|
|
522
|
-
* @example Pool not found
|
|
523
|
-
* ```typescript
|
|
524
|
-
* throw new DexPoolNotFoundError(
|
|
525
|
-
* 'Pool not found: GALA/BENE with fee 3000'
|
|
526
|
-
* );
|
|
527
|
-
* ```
|
|
528
|
-
*
|
|
529
|
-
* @example Catching pool not found errors
|
|
530
|
-
* ```typescript
|
|
531
|
-
* try {
|
|
532
|
-
* const composite = await sdk.dex.pools.getCompositePool(
|
|
533
|
-
* 'GALA|Unit|none|none',
|
|
534
|
-
* 'Token|Unit|BENE|client:123',
|
|
535
|
-
* 3000
|
|
536
|
-
* );
|
|
537
|
-
* } catch (error) {
|
|
538
|
-
* if (error instanceof DexPoolNotFoundError) {
|
|
539
|
-
* console.log('Pool does not exist. Create it first with liquidity.');
|
|
540
|
-
* // Implement pool creation or alternative routing
|
|
541
|
-
* }
|
|
542
|
-
* }
|
|
543
|
-
* ```
|
|
544
|
-
*/
|
|
545
|
-
export declare class DexPoolNotFoundError extends ValidationError {
|
|
546
|
-
/**
|
|
547
|
-
* Creates a new DexPoolNotFoundError
|
|
548
|
-
*
|
|
549
|
-
* @param message - Human-readable error message describing which pool was not found
|
|
550
|
-
*/
|
|
551
|
-
constructor(message: string);
|
|
552
|
-
}
|
|
553
245
|
//# sourceMappingURL=errors.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../src/utils/errors.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAMH;;;;;;;;;;;;;;;;GAgBG;AACH,eAAO,MAAM,WAAW;IACtB,2CAA2C;;IAE3C,+DAA+D;;IAE/D,qDAAqD;;IAErD,mDAAmD;;IAEnD,oCAAoC;;IAEpC,mCAAmC;;IAEnC,oCAAoC;;IAEpC,qCAAqC;;IAErC,0CAA0C;;IAE1C,mCAAmC;;IAEnC,2CAA2C;;IAE3C,uDAAuD;;IAEvD,+CAA+C;;IAE/C,0CAA0C;;IAE1C,0CAA0C;;IAE1C,gDAAgD;;IAEhD,+CAA+C;;CAEvC,CAAC;AAEX;;;;;;;;;;;;;;;GAeG;AACH,MAAM,MAAM,SAAS,GAAG,CAAC,OAAO,WAAW,CAAC,CAAC,MAAM,OAAO,WAAW,CAAC,CAAC;AAEvE;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,qBAAa,eAAgB,SAAQ,KAAK;IAU/B,KAAK,CAAC,EAAE,MAAM;IACd,IAAI,CAAC,EAAE,MAAM;IAVtB;;;;;;OAMG;gBAED,OAAO,EAAE,MAAM,EACR,KAAK,CAAC,EAAE,MAAM,YAAA,EACd,IAAI,CAAC,EAAE,MAAM,YAAA;CAKvB;AAED,kFAAkF;AAClF,qBAAa,oBAAqB,SAAQ,eAAe;gBAC3C,OAAO,EAAE,MAAM;CAI5B;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AACH,qBAAa,YAAa,SAAQ,KAAK;IAU5B,UAAU,CAAC,EAAE,MAAM;IACnB,aAAa,CAAC,EAAE,K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AK,CAAC,EAAE,MAAM;IACd,IAAI,CAAC,EAAE,MAAM;IAVtB;;;;;;OAMG;gBAED,OAAO,EAAE,MAAM,EACR,KAAK,CAAC,EAAE,MAAM,YAAA,EACd,IAAI,CAAC,EAAE,MAAM,YAAA;CAKvB;AAED,kFAAkF;AAClF,qBAAa,oBAAqB,SAAQ,eAAe;gBAC3C,OAAO,EAAE,MAAM;CAI5B;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AACH,qBAAa,YAAa,SAAQ,KAAK;IAU5B,UAAU,CAAC,EAAE,MAAM;IACnB,aAAa,CAAC,EAAE,KAAK;IAV9B;;;;;;OAMG;gBAED,OAAO,EAAE,MAAM,EACR,UAAU,CAAC,EAAE,MAAM,YAAA,EACnB,aAAa,CAAC,EAAE,KAAK,YAAA;CAK/B;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,qBAAa,kBAAmB,SAAQ,KAAK;IASlC,KAAK,CAAC,EAAE,MAAM;IARvB;;;;;OAKG;gBAED,OAAO,EAAE,MAAM,EACR,KAAK,CAAC,EAAE,MAAM,YAAA;CAKxB;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,qBAAa,gBAAiB,SAAQ,KAAK;IAUhC,aAAa,CAAC,EAAE,MAAM;IACtB,IAAI,CAAC,EAAE,MAAM;IAVtB;;;;;;OAMG;gBAED,OAAO,EAAE,MAAM,EACR,aAAa,CAAC,EAAE,MAAM,YAAA,EACtB,IAAI,CAAC,EAAE,MAAM,YAAA;CAKvB"}
|
package/dist/utils/http.d.ts
CHANGED
|
@@ -4,8 +4,9 @@ import type { EIP712Domain, EIP712Types } from '../types/trade.dto';
|
|
|
4
4
|
/**
|
|
5
5
|
* HTTP client with optional signature authentication
|
|
6
6
|
*
|
|
7
|
-
* This client
|
|
8
|
-
*
|
|
7
|
+
* This client adds the `Sign` header to every request using wallet signatures generated by
|
|
8
|
+
* SignatureAuth when a wallet is configured and `signRequests` is on (the default). Clients for
|
|
9
|
+
* hosts other than the launchpad backend turn it off.
|
|
9
10
|
*
|
|
10
11
|
* In read-only mode (no wallet), the client skips authentication headers
|
|
11
12
|
* and allows querying public data endpoints.
|
|
@@ -13,11 +14,22 @@ import type { EIP712Domain, EIP712Types } from '../types/trade.dto';
|
|
|
13
14
|
export declare class HttpClient {
|
|
14
15
|
private readonly axios;
|
|
15
16
|
private readonly auth;
|
|
17
|
+
private readonly signRequests;
|
|
16
18
|
private readonly debug;
|
|
17
19
|
private readonly logger;
|
|
18
20
|
private requestInterceptorId;
|
|
19
21
|
private responseInterceptorId;
|
|
20
|
-
|
|
22
|
+
/**
|
|
23
|
+
* @param auth Signature auth: the request signer for the launchpad backend, and the wallet identity
|
|
24
|
+
* (`getAddress`, `signTypedData`) other services read from this client
|
|
25
|
+
* @param config Base URL, timeout and headers
|
|
26
|
+
* @param options `signRequests: false` keeps the `Sign` header off every request. Only the launchpad
|
|
27
|
+
* backend authenticates with it; the GalaChain gateway, dex-api, the swap backend and the bundler
|
|
28
|
+
* ignore it, and signing each request costs a wallet signature (a prompt for browser wallets).
|
|
29
|
+
*/
|
|
30
|
+
constructor(auth: SignatureAuth | undefined, config?: SDKConfig, options?: {
|
|
31
|
+
readonly signRequests: boolean;
|
|
32
|
+
});
|
|
21
33
|
/**
|
|
22
34
|
* Makes an authenticated HTTP request and returns body only (legacy default).
|
|
23
35
|
*
|
package/dist/utils/http.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"http.d.ts","sourceRoot":"","sources":["../../src/utils/http.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAC3D,OAAO,KAAK,EAEV,oBAAoB,EACpB,aAAa,EACb,SAAS,EACV,MAAM,iBAAiB,CAAC;AACzB,OAAO,KAAK,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAyFpE
|
|
1
|
+
{"version":3,"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AAC,MAAM,EAAE,OAAO,CAAC,GAC/B,OAAO,CAAC,MAAM,CAAC;IAIlB;;;;;;OAMG;IACG,iBAAiB,CACrB,OAAO,EAAE,MAAM,GACd,OAAO,CAAC;QAAE,SAAS,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAC;QAAC,eAAe,EAAE,MAAM,CAAA;KAAE,CAAC;IAsB3E;;OAEG;IACH,OAAO,CAAC,iBAAiB;IA+FzB;;;OAGG;IACH,OAAO,IAAI,IAAI;CAahB"}
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
*
|
|
4
4
|
* These convert FORMATS ONLY. A token class key carries no symbol and a symbol carries no class
|
|
5
5
|
* key, so nothing here infers one from the other: a bare symbol is never expanded into a key.
|
|
6
|
-
* For symbol/metadata use GalaChainService.fetchTokenClassFromChain() or
|
|
6
|
+
* For symbol/metadata use GalaChainService.fetchTokenClassFromChain() or GalaChainService.fetchTokenDetails().
|
|
7
7
|
*
|
|
8
8
|
* @packageDocumentation
|
|
9
9
|
*/
|
|
@@ -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"}
|