@gala-chain/launchpad-sdk 4.0.12 → 4.0.14
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/README.md +1 -1
- package/dist/index.cjs.js +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.esm.js +1 -1
- package/dist/index.js +1 -1
- package/dist/src/LaunchpadSDK.d.ts +199 -17
- package/dist/src/LaunchpadSDK.d.ts.map +1 -1
- package/dist/src/bridge/BridgeService.d.ts +23 -6
- package/dist/src/bridge/BridgeService.d.ts.map +1 -1
- package/dist/src/bridge/index.d.ts +1 -0
- package/dist/src/bridge/index.d.ts.map +1 -1
- package/dist/src/bridge/strategies/EthereumBridgeStrategy.d.ts +13 -0
- package/dist/src/bridge/strategies/EthereumBridgeStrategy.d.ts.map +1 -1
- package/dist/src/bridge/strategies/SolanaBridgeStrategy.d.ts.map +1 -1
- package/dist/src/bridge/types/bridge.dto.d.ts +66 -6
- package/dist/src/bridge/types/bridge.dto.d.ts.map +1 -1
- package/dist/src/bridge/types/bridgeable-token.dto.d.ts +193 -0
- package/dist/src/bridge/types/bridgeable-token.dto.d.ts.map +1 -0
- package/dist/src/bridge/utils/index.d.ts +1 -0
- package/dist/src/bridge/utils/index.d.ts.map +1 -1
- package/dist/src/bridge/utils/tokenIdUtils.d.ts +79 -0
- package/dist/src/bridge/utils/tokenIdUtils.d.ts.map +1 -0
- package/dist/src/constants/version.generated.d.ts +1 -1
- package/dist/src/index.d.ts +1 -0
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/services/BridgeableTokenCache.d.ts +186 -0
- package/dist/src/services/BridgeableTokenCache.d.ts.map +1 -0
- package/dist/src/services/BridgeableTokenService.d.ts +170 -0
- package/dist/src/services/BridgeableTokenService.d.ts.map +1 -0
- package/package.json +2 -1
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Bridgeable Token Service
|
|
3
|
+
*
|
|
4
|
+
* Service for fetching and caching bridgeable tokens from the DEX API.
|
|
5
|
+
* Provides methods to query which tokens can be bridged to Ethereum or Solana,
|
|
6
|
+
* and retrieves their contract addresses dynamically.
|
|
7
|
+
*
|
|
8
|
+
* ## Key Features
|
|
9
|
+
* - Dynamic token discovery (no hardcoded contract addresses)
|
|
10
|
+
* - Permanent caching (bridgeable tokens never change)
|
|
11
|
+
* - Lazy loading (fetches only when needed)
|
|
12
|
+
* - Environment-aware (STAGE vs PROD URLs determine network)
|
|
13
|
+
*
|
|
14
|
+
* ## Caching Strategy
|
|
15
|
+
* - Tokens are cached permanently after first fetch
|
|
16
|
+
* - Separate caches per network (Ethereum, Solana)
|
|
17
|
+
* - Cache persists for entire SDK lifetime
|
|
18
|
+
* - No fallback - API failure throws error
|
|
19
|
+
*
|
|
20
|
+
* @category Services
|
|
21
|
+
* @since 3.33.0
|
|
22
|
+
*/
|
|
23
|
+
import { HttpClient } from '../utils/http.js';
|
|
24
|
+
import { BridgeableTokenCache } from './BridgeableTokenCache.js';
|
|
25
|
+
import type { BridgeableToken, BridgeableNetwork, FetchBridgeableTokensOptions, FetchBridgeableTokensResult, IsTokenBridgeableOptions, IsTokenBridgeableResult } from '../bridge/types/bridgeable-token.dto.js';
|
|
26
|
+
/**
|
|
27
|
+
* BridgeableTokenService
|
|
28
|
+
*
|
|
29
|
+
* Fetches and caches bridgeable token information from the DEX API.
|
|
30
|
+
* Provides efficient lookups for bridge operations.
|
|
31
|
+
*
|
|
32
|
+
* @example Basic usage
|
|
33
|
+
* ```typescript
|
|
34
|
+
* const service = new BridgeableTokenService(dexApiHttp, true);
|
|
35
|
+
*
|
|
36
|
+
* // Fetch all Ethereum-bridgeable tokens
|
|
37
|
+
* const result = await service.fetchAllBridgeableTokensByNetwork('ETHEREUM');
|
|
38
|
+
* console.log(`Found ${result.tokenCount} tokens`);
|
|
39
|
+
*
|
|
40
|
+
* // Check if a specific token is bridgeable
|
|
41
|
+
* const isBridgeable = await service.isTokenBridgeableToNetwork({
|
|
42
|
+
* tokenSymbol: 'GALA',
|
|
43
|
+
* network: 'ETHEREUM'
|
|
44
|
+
* });
|
|
45
|
+
* console.log(`GALA bridgeable to Ethereum: ${isBridgeable.isBridgeable}`);
|
|
46
|
+
*
|
|
47
|
+
* // Get contract address for a token
|
|
48
|
+
* const address = await service.getContractAddress('GWETH', 'ETHEREUM');
|
|
49
|
+
* console.log(`GWETH Ethereum address: ${address}`);
|
|
50
|
+
* ```
|
|
51
|
+
*/
|
|
52
|
+
export declare class BridgeableTokenService {
|
|
53
|
+
private readonly dexApiHttp;
|
|
54
|
+
private readonly logger;
|
|
55
|
+
private readonly cache;
|
|
56
|
+
constructor(dexApiHttp: HttpClient, debugMode?: boolean);
|
|
57
|
+
/**
|
|
58
|
+
* Fetch bridgeable tokens for a network with pagination
|
|
59
|
+
*
|
|
60
|
+
* @param options - Fetch options including network, offset, and limit
|
|
61
|
+
* @returns Promise resolving to fetch result with tokens array
|
|
62
|
+
* @throws NetworkError if API request fails
|
|
63
|
+
*/
|
|
64
|
+
fetchBridgeableTokensByNetwork(options: FetchBridgeableTokensOptions): Promise<FetchBridgeableTokensResult>;
|
|
65
|
+
/**
|
|
66
|
+
* Fetch ALL bridgeable tokens for a network (auto-pagination)
|
|
67
|
+
*
|
|
68
|
+
* Returns cached data if available, otherwise fetches from API.
|
|
69
|
+
* Automatically handles pagination to retrieve all tokens.
|
|
70
|
+
*
|
|
71
|
+
* @param network - Network to fetch tokens for
|
|
72
|
+
* @returns Promise resolving to fetch result with all tokens
|
|
73
|
+
* @throws NetworkError if API request fails
|
|
74
|
+
*/
|
|
75
|
+
fetchAllBridgeableTokensByNetwork(network: BridgeableNetwork): Promise<FetchBridgeableTokensResult>;
|
|
76
|
+
/**
|
|
77
|
+
* Convenience: Fetch all tokens bridgeable to Ethereum
|
|
78
|
+
*
|
|
79
|
+
* @returns Promise resolving to fetch result with Ethereum-bridgeable tokens
|
|
80
|
+
*/
|
|
81
|
+
fetchAllTokensBridgeableToEthereum(): Promise<FetchBridgeableTokensResult>;
|
|
82
|
+
/**
|
|
83
|
+
* Convenience: Fetch all tokens bridgeable to Solana
|
|
84
|
+
*
|
|
85
|
+
* @returns Promise resolving to fetch result with Solana-bridgeable tokens
|
|
86
|
+
*/
|
|
87
|
+
fetchAllTokensBridgeableToSolana(): Promise<FetchBridgeableTokensResult>;
|
|
88
|
+
/**
|
|
89
|
+
* Check if a token is bridgeable to a network
|
|
90
|
+
*
|
|
91
|
+
* Uses cache for efficient lookup. If network not cached, fetches first.
|
|
92
|
+
*
|
|
93
|
+
* @param options - Token symbol and target network
|
|
94
|
+
* @returns Promise resolving to bridgeability result
|
|
95
|
+
*/
|
|
96
|
+
isTokenBridgeableToNetwork(options: IsTokenBridgeableOptions): Promise<IsTokenBridgeableResult>;
|
|
97
|
+
/**
|
|
98
|
+
* Convenience: Check if token is bridgeable to Ethereum
|
|
99
|
+
*
|
|
100
|
+
* @param tokenSymbol - Token symbol to check
|
|
101
|
+
* @returns Promise resolving to bridgeability result
|
|
102
|
+
*/
|
|
103
|
+
isTokenBridgeableToEthereum(tokenSymbol: string): Promise<IsTokenBridgeableResult>;
|
|
104
|
+
/**
|
|
105
|
+
* Convenience: Check if token is bridgeable to Solana
|
|
106
|
+
*
|
|
107
|
+
* @param tokenSymbol - Token symbol to check
|
|
108
|
+
* @returns Promise resolving to bridgeability result
|
|
109
|
+
*/
|
|
110
|
+
isTokenBridgeableToSolana(tokenSymbol: string): Promise<IsTokenBridgeableResult>;
|
|
111
|
+
/**
|
|
112
|
+
* Get token by symbol from cache (or fetch if not cached)
|
|
113
|
+
*
|
|
114
|
+
* @param symbol - Token symbol (case-insensitive)
|
|
115
|
+
* @param network - Network to search
|
|
116
|
+
* @returns Promise resolving to bridgeable token or undefined
|
|
117
|
+
*/
|
|
118
|
+
getTokenBySymbol(symbol: string, network: BridgeableNetwork): Promise<BridgeableToken | undefined>;
|
|
119
|
+
/**
|
|
120
|
+
* Get token by stringified TokenClassKey (tokenId) from cache (or fetch if not cached)
|
|
121
|
+
*
|
|
122
|
+
* @param tokenId - Stringified TokenClassKey (e.g., "GALA|Unit|none|none")
|
|
123
|
+
* @param network - Network to search
|
|
124
|
+
* @returns Promise resolving to bridgeable token or undefined
|
|
125
|
+
*/
|
|
126
|
+
getTokenByTokenId(tokenId: string, network: BridgeableNetwork): Promise<BridgeableToken | undefined>;
|
|
127
|
+
/**
|
|
128
|
+
* Get contract address for a token on a network
|
|
129
|
+
*
|
|
130
|
+
* @param symbol - Token symbol (case-insensitive)
|
|
131
|
+
* @param network - Target network
|
|
132
|
+
* @returns Promise resolving to contract address or undefined
|
|
133
|
+
*/
|
|
134
|
+
getContractAddress(symbol: string, network: BridgeableNetwork): Promise<string | undefined>;
|
|
135
|
+
/**
|
|
136
|
+
* Get all supported token symbols for a network
|
|
137
|
+
*
|
|
138
|
+
* @param network - Network to get symbols for
|
|
139
|
+
* @returns Promise resolving to array of token symbols
|
|
140
|
+
*/
|
|
141
|
+
getSupportedTokenSymbols(network: BridgeableNetwork): Promise<string[]>;
|
|
142
|
+
/**
|
|
143
|
+
* Preload bridgeable tokens for both networks
|
|
144
|
+
*
|
|
145
|
+
* Fetches and caches tokens for Ethereum and Solana in parallel.
|
|
146
|
+
* Useful for eager loading to avoid latency on first bridge operation.
|
|
147
|
+
*/
|
|
148
|
+
preload(): Promise<void>;
|
|
149
|
+
/**
|
|
150
|
+
* Get cache statistics
|
|
151
|
+
*
|
|
152
|
+
* @returns Cache statistics including token counts and timestamps
|
|
153
|
+
*/
|
|
154
|
+
getCacheStats(): ReturnType<BridgeableTokenCache['getStats']>;
|
|
155
|
+
/**
|
|
156
|
+
* Clear cache for a network or all networks
|
|
157
|
+
*
|
|
158
|
+
* @param network - Optional network to clear (clears all if not provided)
|
|
159
|
+
*/
|
|
160
|
+
clearCache(network?: BridgeableNetwork): void;
|
|
161
|
+
/**
|
|
162
|
+
* Transform API response tokens to SDK format
|
|
163
|
+
*
|
|
164
|
+
* @param apiTokens - Raw API response tokens
|
|
165
|
+
* @param targetNetwork - Network being queried
|
|
166
|
+
* @returns Array of transformed bridgeable tokens
|
|
167
|
+
*/
|
|
168
|
+
private transformTokens;
|
|
169
|
+
}
|
|
170
|
+
//# sourceMappingURL=BridgeableTokenService.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"BridgeableTokenService.d.ts","sourceRoot":"","sources":["../../../src/services/BridgeableTokenService.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAE9C,OAAO,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAC;AAGjE,OAAO,KAAK,EACV,eAAe,EACf,iBAAiB,EAGjB,4BAA4B,EAC5B,2BAA2B,EAC3B,wBAAwB,EACxB,uBAAuB,EACxB,MAAM,yCAAyC,CAAC;AAQjD;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,qBAAa,sBAAsB;IAK/B,OAAO,CAAC,QAAQ,CAAC,UAAU;IAJ7B,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAS;IAChC,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAuB;gBAG1B,UAAU,EAAE,UAAU,EACvC,SAAS,GAAE,OAAe;IAS5B;;;;;;OAMG;IACG,8BAA8B,CAClC,OAAO,EAAE,4BAA4B,GACpC,OAAO,CAAC,2BAA2B,CAAC;IA4CvC;;;;;;;;;OASG;IACG,iCAAiC,CACrC,OAAO,EAAE,iBAAiB,GACzB,OAAO,CAAC,2BAA2B,CAAC;IA4DvC;;;;OAIG;IACG,kCAAkC,IAAI,OAAO,CAAC,2BAA2B,CAAC;IAIhF;;;;OAIG;IACG,gCAAgC,IAAI,OAAO,CAAC,2BAA2B,CAAC;IAI9E;;;;;;;OAOG;IACG,0BAA0B,CAC9B,OAAO,EAAE,wBAAwB,GAChC,OAAO,CAAC,uBAAuB,CAAC;IA8BnC;;;;;OAKG;IACG,2BAA2B,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,uBAAuB,CAAC;IAIxF;;;;;OAKG;IACG,yBAAyB,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,uBAAuB,CAAC;IAItF;;;;;;OAMG;IACG,gBAAgB,CACpB,MAAM,EAAE,MAAM,EACd,OAAO,EAAE,iBAAiB,GACzB,OAAO,CAAC,eAAe,GAAG,SAAS,CAAC;IAUvC;;;;;;OAMG;IACG,iBAAiB,CACrB,OAAO,EAAE,MAAM,EACf,OAAO,EAAE,iBAAiB,GACzB,OAAO,CAAC,eAAe,GAAG,SAAS,CAAC;IAUvC;;;;;;OAMG;IACG,kBAAkB,CACtB,MAAM,EAAE,MAAM,EACd,OAAO,EAAE,iBAAiB,GACzB,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC;IAS9B;;;;;OAKG;IACG,wBAAwB,CAAC,OAAO,EAAE,iBAAiB,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC;IAQ7E;;;;;OAKG;IACG,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;IAS9B;;;;OAIG;IACH,aAAa,IAAI,UAAU,CAAC,oBAAoB,CAAC,UAAU,CAAC,CAAC;IAI7D;;;;OAIG;IACH,UAAU,CAAC,OAAO,CAAC,EAAE,iBAAiB,GAAG,IAAI;IAI7C;;;;;;OAMG;IACH,OAAO,CAAC,eAAe;CAuDxB"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gala-chain/launchpad-sdk",
|
|
3
|
-
"version": "4.0.
|
|
3
|
+
"version": "4.0.14",
|
|
4
4
|
"description": "TypeScript SDK for Gala Launchpad Backend API - 100+ public methods with 373+ fully documented APIs supporting optional wallet (read-only and full-access modes). Production-ready DeFi token launchpad integration with AgentConfig setup, GalaChain trading, GSwap DEX integration, price history, token creation, DEX pool discovery, WebSocket event watchers, and comprehensive user operations. Multi-format output (ESM, CJS, UMD).",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/index.esm.js",
|
|
@@ -113,6 +113,7 @@
|
|
|
113
113
|
"demo:bridge:sol:in": "tsx examples/bridge/solana-in.ts",
|
|
114
114
|
"demo:bridge:sol:roundtrip": "tsx examples/bridge/solana-roundtrip.ts",
|
|
115
115
|
"demo:bridge:balances": "tsx examples/bridge/wallet-balances.ts",
|
|
116
|
+
"demo:bridge:bridgeable": "tsx examples/bridge/bridgeable-tokens.ts",
|
|
116
117
|
"test:demos:core": "npm run demo && npm run demo:read-only && npm run demo:authenticated && npm run demo:privatekey-override",
|
|
117
118
|
"test:demos:dex": "npm run demo:dex:pools && npm run demo:dex:pricing && npm run demo:dex:quotes && npm run demo:dex && npm run demo:dex:roundtrip",
|
|
118
119
|
"test:demos:liquidity": "npm run demo:liquidity:all",
|