@gala-chain/launchpad-sdk 8.0.2 → 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 +150 -419
- package/dist/LaunchpadSDK.d.ts.map +1 -1
- package/dist/api/LaunchpadAPI.d.ts +37 -43
- package/dist/api/LaunchpadAPI.d.ts.map +1 -1
- 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/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 +11 -23
- 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/sell-fee-ceiling.d.ts +66 -0
- package/dist/launchpad/sell-fee-ceiling.d.ts.map +1 -0
- package/dist/launchpad/transport.d.ts +2 -1
- package/dist/launchpad/transport.d.ts.map +1 -1
- package/dist/launchpad/writes.d.ts +30 -2
- package/dist/launchpad/writes.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/launchpad.d.ts +4 -4
- package/dist/schemas/launchpad.d.ts.map +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/BundleService.d.ts +9 -1
- package/dist/services/BundleService.d.ts.map +1 -1
- 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 -64
- 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/TradingQuotesService.d.ts +3 -5
- package/dist/services/TradingQuotesService.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 +23 -11
- 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 -269
- 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/session-auth.dto.d.ts +2 -4
- package/dist/types/session-auth.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/trade-quote.d.ts +32 -0
- package/dist/utils/trade-quote.d.ts.map +1 -0
- 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/signing/eip712.d.ts +0 -13
- package/dist/signing/eip712.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
|
@@ -1,209 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Price History Service
|
|
3
|
-
*
|
|
4
|
-
* Handles fetching historical price data for DEX tokens via DEX Backend API.
|
|
5
|
-
*
|
|
6
|
-
* Features:
|
|
7
|
-
* - DEX Backend API integration for token price history
|
|
8
|
-
* - Pagination matching SDK conventions
|
|
9
|
-
* - Date range filtering
|
|
10
|
-
* - Token filtering by TokenClassKey
|
|
11
|
-
* - Comprehensive error handling
|
|
12
|
-
*
|
|
13
|
-
* @category Services
|
|
14
|
-
* @since 3.13.0
|
|
15
|
-
*/
|
|
16
|
-
import type { FetchPriceHistoryOptions, PriceHistoryResult } from '../types/priceHistory.dto';
|
|
17
|
-
import type { HttpClient } from '../utils/http';
|
|
18
|
-
import { BaseService } from './BaseService';
|
|
19
|
-
import type { TokenResolverService } from './TokenResolverService';
|
|
20
|
-
/**
|
|
21
|
-
* Price History Service Class
|
|
22
|
-
*
|
|
23
|
-
* Manages API-based price history queries via DEX Backend API.
|
|
24
|
-
* Supports optional token name resolution via TokenResolverService for convenience.
|
|
25
|
-
*
|
|
26
|
-
* @example
|
|
27
|
-
* ```typescript
|
|
28
|
-
* const httpClient = new HttpClient(config);
|
|
29
|
-
* const tokenResolverService = new TokenResolverService(...);
|
|
30
|
-
* const service = new PriceHistoryService(httpClient, false, tokenResolverService);
|
|
31
|
-
*
|
|
32
|
-
* // Using tokenId
|
|
33
|
-
* const history = await service.fetchPriceHistory({
|
|
34
|
-
* tokenId: { collection: 'GUSDC', category: 'Unit', type: 'none', additionalKey: 'eth:...' },
|
|
35
|
-
* from: new Date('2024-01-01'),
|
|
36
|
-
* to: new Date('2024-01-31'),
|
|
37
|
-
* page: 1,
|
|
38
|
-
* limit: 20
|
|
39
|
-
* });
|
|
40
|
-
*
|
|
41
|
-
* // Using tokenName (auto-resolves to tokenId)
|
|
42
|
-
* const history = await service.fetchPriceHistory({
|
|
43
|
-
* tokenName: 'demonkpop',
|
|
44
|
-
* from: new Date('2024-01-01'),
|
|
45
|
-
* to: new Date('2024-01-31')
|
|
46
|
-
* });
|
|
47
|
-
* ```
|
|
48
|
-
*/
|
|
49
|
-
export declare class PriceHistoryService extends BaseService {
|
|
50
|
-
private readonly tokenResolverService;
|
|
51
|
-
/**
|
|
52
|
-
* Create a new PriceHistoryService instance
|
|
53
|
-
* @param httpClient HTTP client for DEX Backend API
|
|
54
|
-
* @param debugMode Enable debug logging (default: false)
|
|
55
|
-
* @param tokenResolverService Optional TokenResolverService for token name resolution
|
|
56
|
-
*/
|
|
57
|
-
constructor(httpClient: HttpClient, debugMode?: boolean, tokenResolverService?: TokenResolverService);
|
|
58
|
-
/**
|
|
59
|
-
* Helper method: Resolve a token name to its full token class key
|
|
60
|
-
*
|
|
61
|
-
* Uses TokenResolverService to resolve a token name to vault address, then extracts
|
|
62
|
-
* the complete token class key in pipe-delimited format for use with DEX Backend API.
|
|
63
|
-
*
|
|
64
|
-
* @param tokenName Simple token name (e.g., "demonkpop", "shoewars")
|
|
65
|
-
* @returns Promise<string> Full token class key: "collection|category|type|additionalKey"
|
|
66
|
-
* @throws ConfigurationError if TokenResolverService is not available
|
|
67
|
-
* @throws NetworkError if token resolution fails
|
|
68
|
-
* @throws ValidationError if token name is invalid
|
|
69
|
-
*
|
|
70
|
-
* @example
|
|
71
|
-
* ```typescript
|
|
72
|
-
* const tokenClassKey = await service.fetchTokenClassKeyByTokenName('demonkpop');
|
|
73
|
-
* // Returns: "Token|Unit|DKP|eth:4A65D29213de2939373ff9eB63AC38730F192C84"
|
|
74
|
-
* ```
|
|
75
|
-
*
|
|
76
|
-
* @since 3.20.0
|
|
77
|
-
*/
|
|
78
|
-
fetchTokenClassKeyByTokenName(tokenName: string): Promise<string>;
|
|
79
|
-
/**
|
|
80
|
-
* Fetch price history for a token with pagination (v3.20.0+)
|
|
81
|
-
*
|
|
82
|
-
* Fetches historical price snapshots from DEX Backend API with flexible token identification.
|
|
83
|
-
* Returns paginated results matching SDK conventions.
|
|
84
|
-
*
|
|
85
|
-
* Supports three token identification methods (choose exactly ONE):
|
|
86
|
-
* 1. tokenName: Simple token name (e.g., "demonkpop") - auto-resolves to full tokenId
|
|
87
|
-
* 2. tokenId string: Pipe-delimited format (e.g., "Token|Unit|USDC|eth:123...")
|
|
88
|
-
* 3. tokenId object: Explicit TokenClassKey object with collection, category, type, additionalKey
|
|
89
|
-
*
|
|
90
|
-
* @param options Fetch options including token ID (name or full), date range, timeframe, and pagination
|
|
91
|
-
* @returns Promise<PriceHistoryResult> Price snapshots with pagination metadata
|
|
92
|
-
* @throws NetworkError if API request fails
|
|
93
|
-
* @throws ValidationError if parameters are invalid or both tokenName and tokenId are provided
|
|
94
|
-
*
|
|
95
|
-
* @updated 8.1.0 - Uses the market price-series endpoint and local pagination
|
|
96
|
-
*
|
|
97
|
-
* @example
|
|
98
|
-
* ```typescript
|
|
99
|
-
* // NEW (v3.20.0+): Using simple token name (recommended for convenience)
|
|
100
|
-
* const result = await service.fetchPriceHistory({
|
|
101
|
-
* tokenName: 'demonkpop', // Simple, intuitive token name
|
|
102
|
-
* from: new Date('2024-01-01'),
|
|
103
|
-
* to: new Date('2024-01-31'),
|
|
104
|
-
* pageSize: 20
|
|
105
|
-
* });
|
|
106
|
-
*
|
|
107
|
-
* // Using tokenId object format (explicit, no lookup required)
|
|
108
|
-
* const result = await service.fetchPriceHistory({
|
|
109
|
-
* tokenId: {
|
|
110
|
-
* collection: 'GUSDC',
|
|
111
|
-
* category: 'Unit',
|
|
112
|
-
* type: 'none',
|
|
113
|
-
* additionalKey: 'none'
|
|
114
|
-
* },
|
|
115
|
-
* from: new Date('2024-01-01'),
|
|
116
|
-
* to: new Date('2024-01-31'),
|
|
117
|
-
* pageSize: 20
|
|
118
|
-
* });
|
|
119
|
-
*
|
|
120
|
-
* // Using tokenId string format (backward compatible)
|
|
121
|
-
* const result = await service.fetchPriceHistory({
|
|
122
|
-
* tokenId: 'GUSDC|Unit|none|none',
|
|
123
|
-
* pageSize: 20
|
|
124
|
-
* });
|
|
125
|
-
*
|
|
126
|
-
* // Analyzing volatility with date filtering
|
|
127
|
-
* const thirtyDays = await service.fetchPriceHistory({
|
|
128
|
-
* tokenName: 'demonkpop',
|
|
129
|
-
* from: new Date(Date.now() - 30 * 24 * 60 * 60 * 1000),
|
|
130
|
-
* to: new Date(),
|
|
131
|
-
* sortOrder: 'ASC',
|
|
132
|
-
* pageSize: 50
|
|
133
|
-
* });
|
|
134
|
-
* ```
|
|
135
|
-
*
|
|
136
|
-
* @since 3.20.0 - Added tokenName parameter support with auto-resolution
|
|
137
|
-
* @updated 7.0.0 - Migrated from page-based to offset-based pagination
|
|
138
|
-
*/
|
|
139
|
-
fetchPriceHistory(options: FetchPriceHistoryOptions): Promise<PriceHistoryResult>;
|
|
140
|
-
/**
|
|
141
|
-
* Transform DEX Backend API response to SDK PriceHistoryResult format
|
|
142
|
-
* @internal
|
|
143
|
-
*/
|
|
144
|
-
private transformApiResponseToPriceHistory;
|
|
145
|
-
/**
|
|
146
|
-
* Fetch all price history for a token with automatic pagination (v3.20.0+)
|
|
147
|
-
*
|
|
148
|
-
* Convenience method that automatically iterates through all pages from DEX Backend API and combines results.
|
|
149
|
-
* Returns all available price snapshots matching the filter criteria in a single response.
|
|
150
|
-
* No pagination parameters are needed; this method handles offset pagination internally.
|
|
151
|
-
*
|
|
152
|
-
* Supports three token identification methods (choose exactly ONE):
|
|
153
|
-
* 1. tokenName: Simple token name (e.g., "demonkpop") - auto-resolves to full tokenId
|
|
154
|
-
* 2. tokenId string: Pipe-delimited format (e.g., "Token|Unit|USDC|eth:123...")
|
|
155
|
-
* 3. tokenId object: Explicit TokenClassKey object with collection, category, type, additionalKey
|
|
156
|
-
*
|
|
157
|
-
* @param options Fetch options including token ID (name or full), date range, and sort order
|
|
158
|
-
* @returns Promise<PriceHistoryResult> All price snapshots with combined total count
|
|
159
|
-
* @throws NetworkError if API request fails or exceeds maximum pages
|
|
160
|
-
* @throws ValidationError if parameters are invalid or both tokenName and tokenId are provided
|
|
161
|
-
*
|
|
162
|
-
* @example
|
|
163
|
-
* ```typescript
|
|
164
|
-
* // NEW (v3.20.0+): Using simple token name with auto-pagination (recommended)
|
|
165
|
-
* const result = await service.fetchAllPriceHistory({
|
|
166
|
-
* tokenName: 'demonkpop', // Simple token name - auto-resolves
|
|
167
|
-
* from: new Date('2024-01-01'),
|
|
168
|
-
* to: new Date('2024-12-31'),
|
|
169
|
-
* sortOrder: 'ASC'
|
|
170
|
-
* });
|
|
171
|
-
*
|
|
172
|
-
* console.log(`Total snapshots: ${result.total}`);
|
|
173
|
-
* console.log(`Snapshots returned: ${result.snapshots.length}`);
|
|
174
|
-
*
|
|
175
|
-
* // Using tokenId string format (backward compatible, no auto-resolution)
|
|
176
|
-
* const result = await service.fetchAllPriceHistory({
|
|
177
|
-
* tokenId: 'Token|Unit|USDC|eth:123...',
|
|
178
|
-
* from: new Date('2024-01-01'),
|
|
179
|
-
* to: new Date('2024-01-31'),
|
|
180
|
-
* sortOrder: 'DESC'
|
|
181
|
-
* });
|
|
182
|
-
*
|
|
183
|
-
* // Volatility analysis over full year (100+ snapshots with auto-pagination)
|
|
184
|
-
* const yearData = await service.fetchAllPriceHistory({
|
|
185
|
-
* tokenName: 'demonkpop',
|
|
186
|
-
* from: new Date('2023-01-01'),
|
|
187
|
-
* to: new Date('2023-12-31'),
|
|
188
|
-
* sortOrder: 'ASC'
|
|
189
|
-
* });
|
|
190
|
-
*
|
|
191
|
-
* const prices = yearData.snapshots.map(s => parseFloat(s.price));
|
|
192
|
-
* const avgPrice = prices.reduce((a, b) => a + b) / prices.length;
|
|
193
|
-
* console.log(`Average price over year: $${avgPrice.toFixed(8)}`);
|
|
194
|
-
* ```
|
|
195
|
-
*
|
|
196
|
-
* @since 3.20.0 - Added tokenName parameter support with auto-resolution
|
|
197
|
-
* @updated 8.1.0 - Uses the market price-series endpoint and local pagination
|
|
198
|
-
*/
|
|
199
|
-
fetchAllPriceHistory(options: Omit<FetchPriceHistoryOptions, 'cursor' | 'pageSize'>): Promise<PriceHistoryResult>;
|
|
200
|
-
/**
|
|
201
|
-
* Validate fetch options
|
|
202
|
-
* Ensures exactly one of tokenName or tokenId is provided (mutual exclusivity)
|
|
203
|
-
* @private
|
|
204
|
-
*/
|
|
205
|
-
private validateOptions;
|
|
206
|
-
/** Selects the backend-supported window for date-filtered callers. */
|
|
207
|
-
private inferTimeframe;
|
|
208
|
-
}
|
|
209
|
-
//# sourceMappingURL=PriceHistoryService.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"PriceHistoryService.d.ts","sourceRoot":"","sources":["../../src/services/PriceHistoryService.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,KAAK,EACV,wBAAwB,EAExB,kBAAkB,EAGnB,MAAM,2BAA2B,CAAC;AAOnC,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAWhD,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAEnE;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,qBAAa,mBAAoB,SAAQ,WAAW;IAClD,OAAO,CAAC,QAAQ,CAAC,oBAAoB,CAAmC;IAExE;;;;;OAKG;gBACS,UAAU,EAAE,UAAU,EAAE,SAAS,GAAE,OAAe,EAAE,oBAAoB,CAAC,EAAE,oBAAoB;IAK3G;;;;;;;;;;;;;;;;;;;OAmBG;IACG,6BAA6B,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAyDvE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA2DG;IACG,iBAAiB,CAAC,OAAO,EAAE,wBAAwB,GAAG,OAAO,CAAC,kBAAkB,CAAC;IAgEvF;;;OAGG;IACH,OAAO,CAAC,kCAAkC;IAwC1C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAqDG;IACG,oBAAoB,CACxB,OAAO,EAAE,IAAI,CAAC,wBAAwB,EAAE,QAAQ,GAAG,UAAU,CAAC,GAC7D,OAAO,CAAC,kBAAkB,CAAC;IAyC9B;;;;OAIG;IACH,OAAO,CAAC,eAAe;IA4BvB,sEAAsE;IACtE,OAAO,CAAC,cAAc;CAUvB"}
|
|
@@ -1,171 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* WrapService - Cross-channel token wrapping/unwrapping
|
|
3
|
-
*
|
|
4
|
-
* Handles internal GalaChain channel bridges:
|
|
5
|
-
* - Wrap: MUSIC (music channel) → GMUSIC (asset channel)
|
|
6
|
-
* - Unwrap: GMUSIC (asset channel) → MUSIC (music channel)
|
|
7
|
-
*
|
|
8
|
-
* This is different from external bridges (Ethereum/Solana) - wrap/unwrap
|
|
9
|
-
* operates entirely within GalaChain across different channels.
|
|
10
|
-
*
|
|
11
|
-
* @category Services
|
|
12
|
-
* @since 4.0.18
|
|
13
|
-
*/
|
|
14
|
-
import type { Wallet } from 'ethers';
|
|
15
|
-
import type { GalaConnectClient } from '../bridge/GalaConnectClient.js';
|
|
16
|
-
import type { GalaChainSigner } from '../signing/signers.js';
|
|
17
|
-
import type { TokenId } from '../types/common.js';
|
|
18
|
-
import type { UnwrapTokenOptions, WrapTokenOptions, WrapUnwrapFeeEstimate, WrapUnwrapResult, WrapUnwrapStatusResult } from '../types/wrappable-token.dto.js';
|
|
19
|
-
import type { Logger } from '../utils/Logger.js';
|
|
20
|
-
import { LoggerBase } from './BaseService.js';
|
|
21
|
-
import type { WrappableTokenService } from './WrappableTokenService.js';
|
|
22
|
-
/**
|
|
23
|
-
* Configuration for WrapService
|
|
24
|
-
*/
|
|
25
|
-
export interface WrapServiceConfig {
|
|
26
|
-
/** GalaConnect client for DEX API platform (same as bridge operations) */
|
|
27
|
-
galaConnectClient: GalaConnectClient;
|
|
28
|
-
/** WrappableTokenService for token metadata */
|
|
29
|
-
wrappableTokenService: WrappableTokenService;
|
|
30
|
-
/** Optional native GalaChain signer. */
|
|
31
|
-
signer?: GalaChainSigner;
|
|
32
|
-
/** Wallet used to create a native signer when signer is omitted. */
|
|
33
|
-
wallet?: Wallet;
|
|
34
|
-
/** Wallet address (for sender) */
|
|
35
|
-
walletAddress?: string;
|
|
36
|
-
/** Logger instance */
|
|
37
|
-
logger?: Logger;
|
|
38
|
-
}
|
|
39
|
-
/**
|
|
40
|
-
* WrapService - Cross-channel token wrapping/unwrapping
|
|
41
|
-
*
|
|
42
|
-
* Provides methods to wrap tokens from their native channel to the asset channel
|
|
43
|
-
* (e.g., MUSIC → GMUSIC) and unwrap them back (GMUSIC → MUSIC).
|
|
44
|
-
*
|
|
45
|
-
* @example
|
|
46
|
-
* ```typescript
|
|
47
|
-
* // Wrap MUSIC to GMUSIC for DEX trading
|
|
48
|
-
* const wrapResult = await wrapService.wrapToken({
|
|
49
|
-
* tokenId: 'MUSIC',
|
|
50
|
-
* amount: '100',
|
|
51
|
-
* });
|
|
52
|
-
*
|
|
53
|
-
* // Unwrap GMUSIC back to MUSIC
|
|
54
|
-
* const unwrapResult = await wrapService.unwrapToken({
|
|
55
|
-
* tokenId: 'GMUSIC',
|
|
56
|
-
* amount: '50',
|
|
57
|
-
* });
|
|
58
|
-
* ```
|
|
59
|
-
*/
|
|
60
|
-
export declare class WrapService extends LoggerBase {
|
|
61
|
-
private readonly galaConnectClient;
|
|
62
|
-
private readonly wrappableTokenService;
|
|
63
|
-
private readonly nativeSigner;
|
|
64
|
-
private readonly walletAddress;
|
|
65
|
-
constructor(config: WrapServiceConfig);
|
|
66
|
-
/**
|
|
67
|
-
* Wrap a token to its asset-channel counterpart
|
|
68
|
-
*
|
|
69
|
-
* Transfers a token from its native channel to the asset channel.
|
|
70
|
-
* Example: MUSIC (music channel) → GMUSIC (asset channel)
|
|
71
|
-
*
|
|
72
|
-
* @param options - Wrap options including tokenId and amount
|
|
73
|
-
* @returns Promise<WrapUnwrapResult> - Transaction result
|
|
74
|
-
*
|
|
75
|
-
* @example
|
|
76
|
-
* ```typescript
|
|
77
|
-
* const result = await wrapService.wrapToken({
|
|
78
|
-
* tokenId: 'MUSIC',
|
|
79
|
-
* amount: '100',
|
|
80
|
-
* });
|
|
81
|
-
* console.log(`Wrapped ${result.amount} ${result.fromToken} → ${result.toToken}`);
|
|
82
|
-
* ```
|
|
83
|
-
*
|
|
84
|
-
* @throws {ValidationError} If token is not wrappable or already on asset channel
|
|
85
|
-
*/
|
|
86
|
-
wrapToken(options: WrapTokenOptions): Promise<WrapUnwrapResult>;
|
|
87
|
-
/**
|
|
88
|
-
* Unwrap a token back to its native channel
|
|
89
|
-
*
|
|
90
|
-
* Transfers a token from the asset channel back to its native channel.
|
|
91
|
-
* Example: GMUSIC (asset channel) → MUSIC (music channel)
|
|
92
|
-
*
|
|
93
|
-
* @param options - Unwrap options including tokenId and amount
|
|
94
|
-
* @returns Promise<WrapUnwrapResult> - Transaction result
|
|
95
|
-
*
|
|
96
|
-
* @example
|
|
97
|
-
* ```typescript
|
|
98
|
-
* const result = await wrapService.unwrapToken({
|
|
99
|
-
* tokenId: 'GMUSIC',
|
|
100
|
-
* amount: '50',
|
|
101
|
-
* });
|
|
102
|
-
* console.log(`Unwrapped ${result.amount} ${result.fromToken} → ${result.toToken}`);
|
|
103
|
-
* ```
|
|
104
|
-
*
|
|
105
|
-
* @throws {ValidationError} If token is not unwrappable or not on asset channel
|
|
106
|
-
*/
|
|
107
|
-
unwrapToken(options: UnwrapTokenOptions): Promise<WrapUnwrapResult>;
|
|
108
|
-
/**
|
|
109
|
-
* Estimate fees for a wrap operation
|
|
110
|
-
*
|
|
111
|
-
* @param tokenId - Token to wrap
|
|
112
|
-
* @param amount - Amount to wrap
|
|
113
|
-
* @returns Promise<WrapUnwrapFeeEstimate> - Fee estimate
|
|
114
|
-
* @throws ValidationError if tokenId or amount is required but not provided
|
|
115
|
-
*/
|
|
116
|
-
estimateWrapFee(tokenId: TokenId, _amount: string): Promise<WrapUnwrapFeeEstimate>;
|
|
117
|
-
/**
|
|
118
|
-
* Estimate fees for an unwrap operation
|
|
119
|
-
*
|
|
120
|
-
* @param tokenId - Token to unwrap
|
|
121
|
-
* @param amount - Amount to unwrap
|
|
122
|
-
* @returns Promise<WrapUnwrapFeeEstimate> - Fee estimate
|
|
123
|
-
* @throws ValidationError if tokenId or amount is required but not provided
|
|
124
|
-
*/
|
|
125
|
-
estimateUnwrapFee(tokenId: TokenId, _amount: string): Promise<WrapUnwrapFeeEstimate>;
|
|
126
|
-
/**
|
|
127
|
-
* Get status of a wrap/unwrap transaction
|
|
128
|
-
*
|
|
129
|
-
* Cross-channel wrapping completes immediately (synchronous on-chain).
|
|
130
|
-
* This method returns the completed status for the given transaction ID.
|
|
131
|
-
*
|
|
132
|
-
* @param transactionId - Transaction ID to check
|
|
133
|
-
* @returns WrapUnwrapStatusResult - Current status (always completed for wrap/unwrap)
|
|
134
|
-
* @throws ValidationError if transactionId is required but not provided
|
|
135
|
-
*/
|
|
136
|
-
getWrapStatus(transactionId: string): WrapUnwrapStatusResult;
|
|
137
|
-
private executeWrapOrUnwrap;
|
|
138
|
-
private estimateChannelFee;
|
|
139
|
-
/**
|
|
140
|
-
* Execute a cross-channel bridge (wrap or unwrap)
|
|
141
|
-
*
|
|
142
|
-
* Uses the shared native GalaChain signer for the bridge request.
|
|
143
|
-
*
|
|
144
|
-
* @see docs/api-calls/swapBridgeOut.txt for working payload example
|
|
145
|
-
*/
|
|
146
|
-
private executeChannelBridge;
|
|
147
|
-
/**
|
|
148
|
-
* Execute wrap bridge request with comprehensive error handling
|
|
149
|
-
*
|
|
150
|
-
* Uses direct try-catch (not withErrorHandling wrapper) because this method
|
|
151
|
-
* returns structured error responses (WrapUnwrapResult with success: false)
|
|
152
|
-
* rather than throwing. This is appropriate for a private helper method that
|
|
153
|
-
* normalizes errors into the return type.
|
|
154
|
-
*/
|
|
155
|
-
private executeWrapBridgeRequest;
|
|
156
|
-
/**
|
|
157
|
-
* Determine channel routing for wrap/unwrap operation
|
|
158
|
-
*
|
|
159
|
-
* The destinationChannelId determines where tokens go:
|
|
160
|
-
* - Wrap: native channel → asset channel (destinationChannelId = ASSET = 1)
|
|
161
|
-
* - Unwrap: asset channel → native channel (destinationChannelId = MUSIC = 3)
|
|
162
|
-
*/
|
|
163
|
-
private determineChannelRouting;
|
|
164
|
-
private getCounterpartOrThrow;
|
|
165
|
-
private getWrappableTokenOrThrow;
|
|
166
|
-
/**
|
|
167
|
-
* Format tokenId for error messages using centralized stringification
|
|
168
|
-
*/
|
|
169
|
-
private formatTokenId;
|
|
170
|
-
}
|
|
171
|
-
//# sourceMappingURL=WrapService.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"WrapService.d.ts","sourceRoot":"","sources":["../../src/services/WrapService.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAGrC,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,gCAAgC,CAAC;AACxE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAE7D,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,KAAK,EACV,kBAAkB,EAElB,gBAAgB,EAChB,qBAAqB,EACrB,gBAAgB,EAChB,sBAAsB,EACvB,MAAM,iCAAiC,CAAC;AAKzC,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAEjD,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC9C,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAC;AAcxE;;GAEG;AACH,MAAM,WAAW,iBAAiB;IAChC,0EAA0E;IAC1E,iBAAiB,EAAE,iBAAiB,CAAC;IACrC,+CAA+C;IAC/C,qBAAqB,EAAE,qBAAqB,CAAC;IAC7C,wCAAwC;IACxC,MAAM,CAAC,EAAE,eAAe,CAAC;IACzB,oEAAoE;IACpE,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,kCAAkC;IAClC,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,sBAAsB;IACtB,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AA4CD;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,qBAAa,WAAY,SAAQ,UAAU;IACzC,OAAO,CAAC,QAAQ,CAAC,iBAAiB,CAAoB;IACtD,OAAO,CAAC,QAAQ,CAAC,qBAAqB,CAAwB;IAC9D,OAAO,CAAC,QAAQ,CAAC,YAAY,CAA8B;IAC3D,OAAO,CAAC,QAAQ,CAAC,aAAa,CAAqB;gBAEvC,MAAM,EAAE,iBAAiB;IAarC;;;;;;;;;;;;;;;;;;;OAmBG;IACG,SAAS,CAAC,OAAO,EAAE,gBAAgB,GAAG,OAAO,CAAC,gBAAgB,CAAC;IAIrE;;;;;;;;;;;;;;;;;;;OAmBG;IACG,WAAW,CAAC,OAAO,EAAE,kBAAkB,GAAG,OAAO,CAAC,gBAAgB,CAAC;IAIzE;;;;;;;OAOG;IACG,eAAe,CACnB,OAAO,EAAE,OAAO,EAChB,OAAO,EAAE,MAAM,GACd,OAAO,CAAC,qBAAqB,CAAC;IAIjC;;;;;;;OAOG;IACG,iBAAiB,CACrB,OAAO,EAAE,OAAO,EAChB,OAAO,EAAE,MAAM,GACd,OAAO,CAAC,qBAAqB,CAAC;IAIjC;;;;;;;;;OASG;IACH,aAAa,CAAC,aAAa,EAAE,MAAM,GAAG,sBAAsB;YAsB9C,mBAAmB;YA+BnB,kBAAkB;IAoChC;;;;;;OAMG;YACW,oBAAoB;IA0ElC;;;;;;;OAOG;YACW,wBAAwB;IAqItC;;;;;;OAMG;IACH,OAAO,CAAC,uBAAuB;YAwBjB,qBAAqB;YAYrB,wBAAwB;IAYtC;;OAEG;IACH,OAAO,CAAC,aAAa;CAMtB"}
|
|
@@ -1,100 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Wrappable Token Cache Service
|
|
3
|
-
*
|
|
4
|
-
* Permanent in-memory cache for wrappable tokens fetched from DEX API.
|
|
5
|
-
* Wrappable tokens are GalaChain-internal token pairs that can be
|
|
6
|
-
* wrapped/unwrapped into each other (e.g., MUSIC <-> GMUSIC).
|
|
7
|
-
*
|
|
8
|
-
* ## Cache Architecture
|
|
9
|
-
* - **Primary Index**: Map<tokenId, token> - O(1) by stringifiedTokenClassKey
|
|
10
|
-
* - **Persistence**: Entire SDK lifetime (never expires)
|
|
11
|
-
* - **Memory**: ~500-800 bytes per token (plus ~50 bytes per index entry)
|
|
12
|
-
*
|
|
13
|
-
* ## Caching Strategy
|
|
14
|
-
* - Metadata always cached by fetchWrappableTokens/fetchAllWrappableTokens
|
|
15
|
-
* - Balance methods preheat cache while returning user-specific data
|
|
16
|
-
* - No network separation (wrapping is GalaChain-internal)
|
|
17
|
-
*
|
|
18
|
-
* @category Services
|
|
19
|
-
* @since 4.0.18
|
|
20
|
-
*/
|
|
21
|
-
import type { WrappableToken, WrappableTokenCacheStats } from '../types/wrappable-token.dto.js';
|
|
22
|
-
import { BatchedCacheService } from './BatchedCacheService.js';
|
|
23
|
-
/**
|
|
24
|
-
* Wrappable Token Cache
|
|
25
|
-
*
|
|
26
|
-
* High-performance permanent cache for wrappable token data.
|
|
27
|
-
* Tokens are indexed by their stringifiedTokenClassKey for O(1) lookups.
|
|
28
|
-
*
|
|
29
|
-
* @example Basic usage
|
|
30
|
-
* ```typescript
|
|
31
|
-
* const cache = new WrappableTokenCache();
|
|
32
|
-
*
|
|
33
|
-
* // Cache all tokens
|
|
34
|
-
* cache.setAll(wrappableTokens);
|
|
35
|
-
*
|
|
36
|
-
* // Check if cached
|
|
37
|
-
* if (cache.has()) {
|
|
38
|
-
* const tokens = cache.getAll();
|
|
39
|
-
* }
|
|
40
|
-
*
|
|
41
|
-
* // Get specific token by tokenId
|
|
42
|
-
* const music = cache.getByTokenId('$MUSIC|Unit|none|none');
|
|
43
|
-
* ```
|
|
44
|
-
*/
|
|
45
|
-
export declare class WrappableTokenCache extends BatchedCacheService<WrappableToken, WrappableTokenCacheStats> {
|
|
46
|
-
constructor(debugMode?: boolean);
|
|
47
|
-
/**
|
|
48
|
-
* Extract the cache key from a wrappable token
|
|
49
|
-
*
|
|
50
|
-
* @param token - Wrappable token
|
|
51
|
-
* @returns The stringifiedTokenClassKey as the key
|
|
52
|
-
*/
|
|
53
|
-
protected extractKey(token: WrappableToken): string;
|
|
54
|
-
/**
|
|
55
|
-
* Check if cache is populated
|
|
56
|
-
*
|
|
57
|
-
* @returns True if cache has tokens
|
|
58
|
-
*/
|
|
59
|
-
has(): boolean;
|
|
60
|
-
/**
|
|
61
|
-
* Get all cached tokens
|
|
62
|
-
*
|
|
63
|
-
* @returns Array of wrappable tokens (empty if not cached)
|
|
64
|
-
*/
|
|
65
|
-
getAll(): WrappableToken[];
|
|
66
|
-
/**
|
|
67
|
-
* Get a specific token by stringifiedTokenClassKey (tokenId)
|
|
68
|
-
*
|
|
69
|
-
* @param tokenId - Stringified TokenClassKey (e.g., "$MUSIC|Unit|none|none")
|
|
70
|
-
* @returns Wrappable token or undefined if not found
|
|
71
|
-
*/
|
|
72
|
-
getByTokenId(tokenId: string): WrappableToken | undefined;
|
|
73
|
-
/**
|
|
74
|
-
* Get cache statistics
|
|
75
|
-
*
|
|
76
|
-
* @returns Cache statistics including token count and timestamp
|
|
77
|
-
*/
|
|
78
|
-
getStats(): WrappableTokenCacheStats;
|
|
79
|
-
/**
|
|
80
|
-
* Get number of cached tokens
|
|
81
|
-
*
|
|
82
|
-
* @returns Number of cached tokens
|
|
83
|
-
*/
|
|
84
|
-
size(): number;
|
|
85
|
-
/**
|
|
86
|
-
* Check if a token is wrappable (exists in cache)
|
|
87
|
-
*
|
|
88
|
-
* @param tokenId - Stringified TokenClassKey
|
|
89
|
-
* @returns True if token is cached
|
|
90
|
-
*/
|
|
91
|
-
isTokenWrappable(tokenId: string): boolean;
|
|
92
|
-
/**
|
|
93
|
-
* Get wrap counterpart for a token
|
|
94
|
-
*
|
|
95
|
-
* @param tokenId - Stringified TokenClassKey
|
|
96
|
-
* @returns Counterpart token or undefined if not found
|
|
97
|
-
*/
|
|
98
|
-
getWrapCounterpart(tokenId: string): WrappableToken | undefined;
|
|
99
|
-
}
|
|
100
|
-
//# sourceMappingURL=WrappableTokenCache.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"WrappableTokenCache.d.ts","sourceRoot":"","sources":["../../src/services/WrappableTokenCache.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAE,wBAAwB,EAAE,MAAM,iCAAiC,CAAC;AAChG,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAE/D;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,qBAAa,mBAAoB,SAAQ,mBAAmB,CAAC,cAAc,EAAE,wBAAwB,CAAC;gBACxF,SAAS,GAAE,OAAe;IAItC;;;;;OAKG;IACH,SAAS,CAAC,UAAU,CAAC,KAAK,EAAE,cAAc,GAAG,MAAM;IAInD;;;;OAIG;IACM,GAAG,IAAI,OAAO;IAIvB;;;;OAIG;IACH,MAAM,IAAI,cAAc,EAAE;IAI1B;;;;;OAKG;IACI,YAAY,CAAC,OAAO,EAAE,MAAM,GAAG,cAAc,GAAG,SAAS;IAIhE;;;;OAIG;IACa,QAAQ,IAAI,wBAAwB;IAQpD;;;;OAIG;IACM,IAAI,IAAI,MAAM;IAIvB;;;;;OAKG;IACH,gBAAgB,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO;IAI1C;;;;;OAKG;IACH,kBAAkB,CAAC,OAAO,EAAE,MAAM,GAAG,cAAc,GAAG,SAAS;CAMhE"}
|
|
@@ -1,130 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Wrappable Token Service
|
|
3
|
-
*
|
|
4
|
-
* Service for fetching and caching wrappable tokens from the DEX API.
|
|
5
|
-
* Provides methods to query which tokens can be wrapped/unwrapped
|
|
6
|
-
* and retrieves their counterpart tokens dynamically.
|
|
7
|
-
*
|
|
8
|
-
* ## Key Features
|
|
9
|
-
* - Dynamic token discovery (fetches from DEX API)
|
|
10
|
-
* - Permanent caching for token metadata
|
|
11
|
-
* - Separate balance methods for user-specific queries
|
|
12
|
-
*
|
|
13
|
-
* ## Caching Strategy
|
|
14
|
-
* - Token metadata is always cached (fetchWrappableTokens, fetchAllWrappableTokens)
|
|
15
|
-
* - Balance methods never cache (fetchWrappableTokenBalances, fetchAllWrappableTokenBalances)
|
|
16
|
-
* - Cache persists for entire SDK lifetime
|
|
17
|
-
*
|
|
18
|
-
* @category Services
|
|
19
|
-
* @since 4.0.18
|
|
20
|
-
*/
|
|
21
|
-
import type { TokenId } from '../types/common.js';
|
|
22
|
-
import type { FetchWrappableTokensOptions, FetchWrappableTokensResult, IsTokenWrappableResult, WrappableToken, WrappableTokenApiResponse, WrappableTokenCacheStats } from '../types/wrappable-token.dto.js';
|
|
23
|
-
import type { HttpClient } from '../utils/http.js';
|
|
24
|
-
import { AbstractTokenFetchService } from './AbstractTokenFetchService.js';
|
|
25
|
-
/**
|
|
26
|
-
* WrappableTokenService
|
|
27
|
-
*
|
|
28
|
-
* Fetches and caches wrappable token information from the DEX API.
|
|
29
|
-
* Provides efficient lookups for wrap/unwrap operations.
|
|
30
|
-
*
|
|
31
|
-
* @example Basic usage
|
|
32
|
-
* ```typescript
|
|
33
|
-
* const service = new WrappableTokenService(dexApiHttp, true);
|
|
34
|
-
*
|
|
35
|
-
* // Fetch all wrappable tokens (cached)
|
|
36
|
-
* const result = await service.fetchAllWrappableTokens();
|
|
37
|
-
* console.log(`Found ${result.tokenCount} tokens`);
|
|
38
|
-
*
|
|
39
|
-
* // Fetch with balance data for a specific address (not cached)
|
|
40
|
-
* const withBalances = await service.fetchAllWrappableTokenBalances('eth|0x1234...');
|
|
41
|
-
* console.log(`Found ${withBalances.tokenCount} tokens with balances`);
|
|
42
|
-
*
|
|
43
|
-
* // Check if a specific token is wrappable (by tokenId)
|
|
44
|
-
* const isWrappable = await service.isTokenWrappable('$MUSIC|Unit|none|none');
|
|
45
|
-
* console.log(`MUSIC wrappable: ${isWrappable.isWrappable}`);
|
|
46
|
-
*
|
|
47
|
-
* // Get wrap counterpart
|
|
48
|
-
* const counterpart = await service.getWrapCounterpart('$MUSIC|Unit|none|none');
|
|
49
|
-
* console.log(`MUSIC counterpart: ${counterpart?.symbol}`); // GMUSIC
|
|
50
|
-
* ```
|
|
51
|
-
*/
|
|
52
|
-
export declare class WrappableTokenService extends AbstractTokenFetchService<WrappableTokenApiResponse, WrappableToken> {
|
|
53
|
-
private readonly cache;
|
|
54
|
-
constructor(dexApiHttp: HttpClient, debugMode?: boolean);
|
|
55
|
-
/**
|
|
56
|
-
* Build API request parameters for wrappable tokens
|
|
57
|
-
*
|
|
58
|
-
* @param _context - Unused context parameter (required by base class)
|
|
59
|
-
* @returns Query parameters with wrappable filter
|
|
60
|
-
*/
|
|
61
|
-
protected buildApiParams(context?: Record<string, unknown>): Record<string, string | number | boolean>;
|
|
62
|
-
/**
|
|
63
|
-
* Transform API response tokens to SDK format
|
|
64
|
-
*
|
|
65
|
-
* @param apiTokens - Raw API response tokens
|
|
66
|
-
* @returns Array of transformed wrappable tokens
|
|
67
|
-
*/
|
|
68
|
-
protected transformApiResponse(apiTokens: WrappableTokenApiResponse[]): WrappableToken[];
|
|
69
|
-
/**
|
|
70
|
-
* Fetch wrappable tokens with pagination (metadata only, cached)
|
|
71
|
-
*
|
|
72
|
-
* For user-specific balance data, use fetchWrappableTokenBalances() instead.
|
|
73
|
-
*
|
|
74
|
-
* @param options - Fetch options including pagination parameters
|
|
75
|
-
* @returns Promise resolving to fetch result with tokens array
|
|
76
|
-
* @throws NetworkError if API request fails
|
|
77
|
-
*/
|
|
78
|
-
fetchWrappableTokens(options?: FetchWrappableTokensOptions): Promise<FetchWrappableTokensResult>;
|
|
79
|
-
/**
|
|
80
|
-
* Fetch ALL wrappable tokens (auto-pagination, cached)
|
|
81
|
-
*
|
|
82
|
-
* Returns cached data if available, otherwise fetches from API.
|
|
83
|
-
* For user-specific balance data, use fetchAllWrappableTokenBalances() instead.
|
|
84
|
-
*
|
|
85
|
-
* @returns Promise resolving to fetch result with all tokens
|
|
86
|
-
* @throws NetworkError if API request fails
|
|
87
|
-
*/
|
|
88
|
-
fetchAllWrappableTokens(): Promise<FetchWrappableTokensResult>;
|
|
89
|
-
/**
|
|
90
|
-
* Get a wrappable token by tokenId
|
|
91
|
-
*
|
|
92
|
-
* Uses cache for efficient lookup. If cache not populated, fetches first.
|
|
93
|
-
*
|
|
94
|
-
* @param tokenId - Token identifier (pipe-delimited or TokenClassKey)
|
|
95
|
-
* @returns Promise resolving to wrappable token or undefined
|
|
96
|
-
*/
|
|
97
|
-
getWrappableToken(tokenId: TokenId): Promise<WrappableToken | undefined>;
|
|
98
|
-
/**
|
|
99
|
-
* Get the wrap counterpart for a token
|
|
100
|
-
*
|
|
101
|
-
* @param tokenId - Token identifier (pipe-delimited or TokenClassKey)
|
|
102
|
-
* @returns Promise resolving to counterpart token or undefined
|
|
103
|
-
*
|
|
104
|
-
* @example
|
|
105
|
-
* ```typescript
|
|
106
|
-
* // Get GMUSIC from MUSIC
|
|
107
|
-
* const counterpart = await service.getWrapCounterpart('$MUSIC|Unit|none|none');
|
|
108
|
-
* console.log(counterpart?.symbol); // "GMUSIC"
|
|
109
|
-
* ```
|
|
110
|
-
*/
|
|
111
|
-
getWrapCounterpart(tokenId: TokenId): Promise<WrappableToken | undefined>;
|
|
112
|
-
/**
|
|
113
|
-
* Check if a token is wrappable
|
|
114
|
-
*
|
|
115
|
-
* @param tokenId - Token identifier (pipe-delimited or TokenClassKey)
|
|
116
|
-
* @returns Promise resolving to wrappability result
|
|
117
|
-
*/
|
|
118
|
-
isTokenWrappable(tokenId: TokenId): Promise<IsTokenWrappableResult>;
|
|
119
|
-
/**
|
|
120
|
-
* Get cache statistics
|
|
121
|
-
*
|
|
122
|
-
* @returns Cache statistics including token count and timestamp
|
|
123
|
-
*/
|
|
124
|
-
getCacheStats(): WrappableTokenCacheStats;
|
|
125
|
-
/**
|
|
126
|
-
* Clear cache
|
|
127
|
-
*/
|
|
128
|
-
clearCache(): void;
|
|
129
|
-
}
|
|
130
|
-
//# sourceMappingURL=WrappableTokenService.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"WrappableTokenService.d.ts","sourceRoot":"","sources":["../../src/services/WrappableTokenService.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,KAAK,EACV,2BAA2B,EAC3B,0BAA0B,EAC1B,sBAAsB,EACtB,cAAc,EACd,yBAAyB,EACzB,wBAAwB,EACzB,MAAM,iCAAiC,CAAC;AAGzC,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAEnD,OAAO,EAAE,yBAAyB,EAAE,MAAM,gCAAgC,CAAC;AAI3E;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,qBAAa,qBAAsB,SAAQ,yBAAyB,CAClE,yBAAyB,EACzB,cAAc,CACf;IACC,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAsB;gBAEhC,UAAU,EAAE,UAAU,EAAE,SAAS,GAAE,OAAe;IAK9D;;;;;OAKG;IACH,SAAS,CAAC,cAAc,CACtB,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAChC,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC;IAK5C;;;;;OAKG;IACH,SAAS,CAAC,oBAAoB,CAAC,SAAS,EAAE,yBAAyB,EAAE,GAAG,cAAc,EAAE;IAwCxF;;;;;;;;OAQG;IACG,oBAAoB,CACxB,OAAO,GAAE,2BAAgC,GACxC,OAAO,CAAC,0BAA0B,CAAC;IAoCtC;;;;;;;;OAQG;IACG,uBAAuB,IAAI,OAAO,CAAC,0BAA0B,CAAC;IAqBpE;;;;;;;OAOG;IACG,iBAAiB,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC,cAAc,GAAG,SAAS,CAAC;IAqB9E;;;;;;;;;;;;OAYG;IACG,kBAAkB,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC,cAAc,GAAG,SAAS,CAAC;IAO/E;;;;;OAKG;IACG,gBAAgB,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC,sBAAsB,CAAC;IA6BzE;;;;OAIG;IACH,aAAa,IAAI,wBAAwB;IAIzC;;OAEG;IACH,UAAU,IAAI,IAAI;CAGnB"}
|
package/dist/setup.d.ts
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Vitest setup file for test environment configuration
|
|
3
|
-
*
|
|
4
|
-
* This file is placed in src/ to satisfy TypeScript's rootDir configuration
|
|
5
|
-
* while remaining in the test environment setup pipeline via vitest.config.ts
|
|
6
|
-
*/
|
|
7
|
-
export {};
|
|
8
|
-
//# sourceMappingURL=setup.d.ts.map
|
package/dist/setup.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"setup.d.ts","sourceRoot":"","sources":["../src/setup.ts"],"names":[],"mappings":"AAAA;;;;;GAKG"}
|
package/dist/signing/eip712.d.ts
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import type { EIP712Types } from './types';
|
|
2
|
-
/**
|
|
3
|
-
* Generate the recursive EIP-712 types used by launchpad bundle writes.
|
|
4
|
-
*
|
|
5
|
-
* Primitive values map to string, uint256, and bool. Nested objects become
|
|
6
|
-
* named structs and arrays use the generated element type.
|
|
7
|
-
*
|
|
8
|
-
* @example
|
|
9
|
-
* const types = generateEIP712Types('BuyWithNative', { amount: '1', exact: true });
|
|
10
|
-
* console.log(types.BuyWithNative);
|
|
11
|
-
*/
|
|
12
|
-
export declare function generateEIP712Types(typeName: string, params: Record<string, unknown>): EIP712Types;
|
|
13
|
-
//# sourceMappingURL=eip712.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"eip712.d.ts","sourceRoot":"","sources":["../../src/signing/eip712.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAmB,MAAM,SAAS,CAAC;AAE5D;;;;;;;;;GASG;AACH,wBAAgB,mBAAmB,CACjC,QAAQ,EAAE,MAAM,EAChB,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAC9B,WAAW,CAuFb"}
|