@gala-chain/launchpad-sdk 4.0.6 → 4.0.7-beta.10
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 +174 -4
- package/dist/index.cjs.js +1 -1
- package/dist/index.d.ts +3 -1
- 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 +214 -1
- package/dist/src/LaunchpadSDK.d.ts.map +1 -1
- package/dist/src/bridge/BridgeService.d.ts +364 -0
- package/dist/src/bridge/BridgeService.d.ts.map +1 -0
- package/dist/src/bridge/GalaConnectClient.d.ts +164 -0
- package/dist/src/bridge/GalaConnectClient.d.ts.map +1 -0
- package/dist/src/bridge/constants/index.d.ts +7 -0
- package/dist/src/bridge/constants/index.d.ts.map +1 -0
- package/dist/src/bridge/constants/tokens.d.ts +181 -0
- package/dist/src/bridge/constants/tokens.d.ts.map +1 -0
- package/dist/src/bridge/index.d.ts +22 -0
- package/dist/src/bridge/index.d.ts.map +1 -0
- package/dist/src/bridge/strategies/BridgeStrategy.d.ts +160 -0
- package/dist/src/bridge/strategies/BridgeStrategy.d.ts.map +1 -0
- package/dist/src/bridge/strategies/EthereumBridgeStrategy.d.ts +198 -0
- package/dist/src/bridge/strategies/EthereumBridgeStrategy.d.ts.map +1 -0
- package/dist/src/bridge/strategies/SolanaBridgeStrategy.d.ts +207 -0
- package/dist/src/bridge/strategies/SolanaBridgeStrategy.d.ts.map +1 -0
- package/dist/src/bridge/strategies/index.d.ts +9 -0
- package/dist/src/bridge/strategies/index.d.ts.map +1 -0
- package/dist/src/bridge/types/bridge.dto.d.ts +618 -0
- package/dist/src/bridge/types/bridge.dto.d.ts.map +1 -0
- package/dist/src/bridge/types/eip712.d.ts +57 -0
- package/dist/src/bridge/types/eip712.d.ts.map +1 -0
- package/dist/src/bridge/types/index.d.ts +8 -0
- package/dist/src/bridge/types/index.d.ts.map +1 -0
- package/dist/src/bridge/utils/RateLimiter.d.ts +34 -0
- package/dist/src/bridge/utils/RateLimiter.d.ts.map +1 -0
- package/dist/src/bridge/utils/index.d.ts +9 -0
- package/dist/src/bridge/utils/index.d.ts.map +1 -0
- package/dist/src/bridge/utils/retry.d.ts +96 -0
- package/dist/src/bridge/utils/retry.d.ts.map +1 -0
- package/dist/src/bridge/utils/tokenMath.d.ts +39 -0
- package/dist/src/bridge/utils/tokenMath.d.ts.map +1 -0
- package/dist/src/constants/version.generated.d.ts +1 -1
- package/dist/src/constants/version.generated.d.ts.map +1 -1
- package/dist/src/index.d.ts +3 -1
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/services/DexBackendClient.d.ts +51 -1
- package/dist/src/services/DexBackendClient.d.ts.map +1 -1
- package/dist/src/services/GSwapService.d.ts +62 -8
- package/dist/src/services/GSwapService.d.ts.map +1 -1
- package/dist/src/types/galachain-api.types.d.ts +28 -0
- package/dist/src/types/galachain-api.types.d.ts.map +1 -1
- package/dist/src/types/gswap.dto.d.ts +43 -4
- package/dist/src/types/gswap.dto.d.ts.map +1 -1
- package/dist/src/utils/validation-helpers.d.ts +9 -1
- package/dist/src/utils/validation-helpers.d.ts.map +1 -1
- package/package.json +19 -2
|
@@ -0,0 +1,364 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Bridge Service
|
|
3
|
+
*
|
|
4
|
+
* Main orchestrator for cross-chain bridging operations.
|
|
5
|
+
* Provides a unified API for bridging tokens between GalaChain and external chains.
|
|
6
|
+
*/
|
|
7
|
+
import type { BridgeConfig, BridgeFeeEstimate, BridgeInParams, BridgeOutParams, BridgeStatus, BridgeToken, BridgeTransaction, ExternalNetwork, WaitForBridgeOptions, ExternalChainBalance, EthereumWalletBalanceResult, SolanaWalletBalanceResult } from './types/index.js';
|
|
8
|
+
import { type BridgeEnvironment } from './constants/index.js';
|
|
9
|
+
export type { BridgeEnvironment };
|
|
10
|
+
/**
|
|
11
|
+
* Extended bridge configuration with wallet keys.
|
|
12
|
+
*/
|
|
13
|
+
export interface BridgeServiceConfig extends BridgeConfig {
|
|
14
|
+
/** GalaChain wallet address (eth|0x...) */
|
|
15
|
+
galaChainWalletAddress: string;
|
|
16
|
+
/** Ethereum private key for signing (required for all operations) */
|
|
17
|
+
ethereumPrivateKey: string;
|
|
18
|
+
/** Environment - affects default RPC URLs (STAGE uses Sepolia, PROD uses mainnet) */
|
|
19
|
+
environment?: BridgeEnvironment;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Bridge Service - Main entry point for cross-chain operations.
|
|
23
|
+
*
|
|
24
|
+
* Supports bridging between:
|
|
25
|
+
* - GalaChain ↔ Ethereum (6 tokens: GALA, GWETH, GUSDC, GUSDT, GWTRX, GWBTC)
|
|
26
|
+
* - GalaChain ↔ Solana (2 tokens: GALA, GSOL)
|
|
27
|
+
*
|
|
28
|
+
* @example
|
|
29
|
+
* ```typescript
|
|
30
|
+
* const bridgeService = new BridgeService({
|
|
31
|
+
* // Uses GALACONNECT_PRODUCTION_URL by default
|
|
32
|
+
* galaChainWalletAddress: 'eth|0x1234...',
|
|
33
|
+
* ethereumPrivateKey: '0xabcd...',
|
|
34
|
+
* solanaPrivateKey: 'base58EncodedKey...',
|
|
35
|
+
* });
|
|
36
|
+
*
|
|
37
|
+
* // Estimate bridge fees
|
|
38
|
+
* const fee = await bridgeService.estimateBridgeFee({
|
|
39
|
+
* tokenSymbol: 'GALA',
|
|
40
|
+
* destinationChain: 'Ethereum',
|
|
41
|
+
* amount: '100',
|
|
42
|
+
* });
|
|
43
|
+
*
|
|
44
|
+
* // Bridge out (GalaChain → Ethereum)
|
|
45
|
+
* const tx = await bridgeService.bridgeOut({
|
|
46
|
+
* tokenSymbol: 'GALA',
|
|
47
|
+
* amount: '100',
|
|
48
|
+
* destinationChain: 'Ethereum',
|
|
49
|
+
* recipientAddress: '0x5678...',
|
|
50
|
+
* });
|
|
51
|
+
*
|
|
52
|
+
* // Wait for completion
|
|
53
|
+
* const status = await bridgeService.waitForBridgeCompletion(tx.transactionHash);
|
|
54
|
+
* ```
|
|
55
|
+
*/
|
|
56
|
+
export declare class BridgeService {
|
|
57
|
+
private readonly config;
|
|
58
|
+
private readonly galaConnectClient;
|
|
59
|
+
private readonly strategies;
|
|
60
|
+
/**
|
|
61
|
+
* Normalize a GalaChain wallet address to the expected format.
|
|
62
|
+
*
|
|
63
|
+
* GalaChain expects: `eth|<checksummed-address-without-0x>`
|
|
64
|
+
*
|
|
65
|
+
* Accepts various formats:
|
|
66
|
+
* - `eth|0xa278...` → `eth|A278...` (removes 0x, checksums)
|
|
67
|
+
* - `eth|a278...` → `eth|A278...` (checksums)
|
|
68
|
+
* - `0xA278...` → `eth|A278...` (adds prefix, removes 0x)
|
|
69
|
+
*
|
|
70
|
+
* @param address - Wallet address in any supported format
|
|
71
|
+
* @returns Normalized address in GalaChain format
|
|
72
|
+
*/
|
|
73
|
+
private static normalizeGalaChainAddress;
|
|
74
|
+
/**
|
|
75
|
+
* Compute EIP-55 checksum for an address.
|
|
76
|
+
*
|
|
77
|
+
* @param address - Address without 0x prefix (40 hex chars)
|
|
78
|
+
* @returns Checksummed address (40 chars, mixed case)
|
|
79
|
+
*/
|
|
80
|
+
private static checksumAddress;
|
|
81
|
+
/**
|
|
82
|
+
* Creates a new Bridge Service.
|
|
83
|
+
*
|
|
84
|
+
* @param config - Service configuration
|
|
85
|
+
*/
|
|
86
|
+
constructor(config: BridgeServiceConfig);
|
|
87
|
+
/**
|
|
88
|
+
* Initialize bridge strategies for supported chains.
|
|
89
|
+
*/
|
|
90
|
+
private initializeStrategies;
|
|
91
|
+
/**
|
|
92
|
+
* Estimate bridge fees for a transfer.
|
|
93
|
+
*
|
|
94
|
+
* @param params - Fee estimation parameters
|
|
95
|
+
* @returns Fee estimate with breakdown
|
|
96
|
+
*/
|
|
97
|
+
estimateBridgeFee(params: {
|
|
98
|
+
tokenSymbol: string;
|
|
99
|
+
destinationChain: ExternalNetwork;
|
|
100
|
+
amount?: string;
|
|
101
|
+
}): Promise<BridgeFeeEstimate>;
|
|
102
|
+
/**
|
|
103
|
+
* Bridge tokens out from GalaChain to an external chain.
|
|
104
|
+
*
|
|
105
|
+
* @param params - Bridge out parameters
|
|
106
|
+
* @returns Transaction details
|
|
107
|
+
*/
|
|
108
|
+
bridgeOut(params: BridgeOutParams): Promise<BridgeTransaction>;
|
|
109
|
+
/**
|
|
110
|
+
* Bridge tokens in from an external chain to GalaChain.
|
|
111
|
+
*
|
|
112
|
+
* @param params - Bridge in parameters
|
|
113
|
+
* @returns Transaction details
|
|
114
|
+
*/
|
|
115
|
+
bridgeIn(params: BridgeInParams): Promise<BridgeTransaction>;
|
|
116
|
+
/**
|
|
117
|
+
* Get the status of a bridge transaction.
|
|
118
|
+
*
|
|
119
|
+
* @param transactionHash - Transaction hash to check
|
|
120
|
+
* @param chain - Optional chain hint for faster lookup (if known)
|
|
121
|
+
* @returns Current status
|
|
122
|
+
*/
|
|
123
|
+
getBridgeStatus(transactionHash: string, chain?: ExternalNetwork): Promise<BridgeStatus>;
|
|
124
|
+
/**
|
|
125
|
+
* Wait for a bridge transaction to complete.
|
|
126
|
+
*
|
|
127
|
+
* @param transactionHash - Transaction hash to wait for
|
|
128
|
+
* @param options - Polling options
|
|
129
|
+
* @returns Final status when complete
|
|
130
|
+
*/
|
|
131
|
+
waitForBridgeCompletion(transactionHash: string, options?: WaitForBridgeOptions): Promise<BridgeStatus>;
|
|
132
|
+
/**
|
|
133
|
+
* Get list of all supported bridge tokens.
|
|
134
|
+
*
|
|
135
|
+
* @param chain - Optional chain to filter by
|
|
136
|
+
* @returns Array of supported tokens
|
|
137
|
+
*/
|
|
138
|
+
getSupportedBridgeTokens(chain?: ExternalNetwork): BridgeToken[];
|
|
139
|
+
/**
|
|
140
|
+
* Get list of supported external chains.
|
|
141
|
+
*
|
|
142
|
+
* @returns Array of chain names
|
|
143
|
+
*/
|
|
144
|
+
getSupportedBridgeChains(): ExternalNetwork[];
|
|
145
|
+
/**
|
|
146
|
+
* Check if a token is supported for bridging.
|
|
147
|
+
*
|
|
148
|
+
* @param tokenSymbol - Token symbol to check
|
|
149
|
+
* @param chain - Optional chain to check specifically
|
|
150
|
+
* @returns True if token is supported
|
|
151
|
+
*/
|
|
152
|
+
isTokenSupported(tokenSymbol: string, chain?: ExternalNetwork): boolean;
|
|
153
|
+
/**
|
|
154
|
+
* Validate an address for a specific chain.
|
|
155
|
+
*
|
|
156
|
+
* @param address - Address to validate
|
|
157
|
+
* @param chain - Target chain
|
|
158
|
+
* @returns True if address is valid
|
|
159
|
+
*/
|
|
160
|
+
isValidAddress(address: string, chain: ExternalNetwork): boolean;
|
|
161
|
+
/**
|
|
162
|
+
* Get ERC-20 token balance on Ethereum.
|
|
163
|
+
*
|
|
164
|
+
* @param tokenSymbol - Token symbol (e.g., 'GALA', 'GWETH', 'GUSDC')
|
|
165
|
+
* @param address - Optional Ethereum address (defaults to configured wallet)
|
|
166
|
+
* @returns Token balance as decimal string
|
|
167
|
+
* @throws Error if Ethereum bridge not configured or token not supported
|
|
168
|
+
*
|
|
169
|
+
* @example
|
|
170
|
+
* ```typescript
|
|
171
|
+
* // Check wallet's GALA balance on Ethereum
|
|
172
|
+
* const balance = await bridge.getEthereumTokenBalance('GALA');
|
|
173
|
+
* console.log(`Ethereum GALA: ${balance}`);
|
|
174
|
+
*
|
|
175
|
+
* // Check specific address
|
|
176
|
+
* const otherBalance = await bridge.getEthereumTokenBalance('GUSDC', '0x1234...');
|
|
177
|
+
* ```
|
|
178
|
+
*/
|
|
179
|
+
getEthereumTokenBalance(tokenSymbol: string, address?: string): Promise<string>;
|
|
180
|
+
/**
|
|
181
|
+
* Get native ETH balance on Ethereum.
|
|
182
|
+
*
|
|
183
|
+
* @param address - Optional Ethereum address (defaults to configured wallet)
|
|
184
|
+
* @returns ETH balance as decimal string (18 decimals)
|
|
185
|
+
* @throws Error if Ethereum bridge not configured
|
|
186
|
+
*
|
|
187
|
+
* @example
|
|
188
|
+
* ```typescript
|
|
189
|
+
* // Check wallet's ETH balance (for gas fees)
|
|
190
|
+
* const ethBalance = await bridge.getEthereumNativeBalance();
|
|
191
|
+
* console.log(`ETH for gas: ${ethBalance}`);
|
|
192
|
+
* ```
|
|
193
|
+
*/
|
|
194
|
+
getEthereumNativeBalance(address?: string): Promise<string>;
|
|
195
|
+
/**
|
|
196
|
+
* Get SPL token balance on Solana.
|
|
197
|
+
*
|
|
198
|
+
* @param tokenSymbol - Token symbol ('GALA' or 'GSOL')
|
|
199
|
+
* @param address - Optional Solana address (defaults to configured wallet)
|
|
200
|
+
* @returns Token balance as decimal string
|
|
201
|
+
* @throws Error if Solana bridge not configured or token not supported
|
|
202
|
+
*
|
|
203
|
+
* @example
|
|
204
|
+
* ```typescript
|
|
205
|
+
* // Check wallet's GALA balance on Solana
|
|
206
|
+
* const balance = await bridge.getSolanaTokenBalance('GALA');
|
|
207
|
+
* console.log(`Solana GALA: ${balance}`);
|
|
208
|
+
* ```
|
|
209
|
+
*/
|
|
210
|
+
getSolanaTokenBalance(tokenSymbol: string, address?: string): Promise<string>;
|
|
211
|
+
/**
|
|
212
|
+
* Get native SOL balance on Solana.
|
|
213
|
+
*
|
|
214
|
+
* @param address - Optional Solana address (defaults to configured wallet)
|
|
215
|
+
* @returns SOL balance as decimal string (9 decimals)
|
|
216
|
+
* @throws Error if Solana bridge not configured
|
|
217
|
+
*
|
|
218
|
+
* @example
|
|
219
|
+
* ```typescript
|
|
220
|
+
* // Check wallet's SOL balance (for transaction fees)
|
|
221
|
+
* const solBalance = await bridge.getSolanaNativeBalance();
|
|
222
|
+
* console.log(`SOL for rent: ${solBalance}`);
|
|
223
|
+
* ```
|
|
224
|
+
*/
|
|
225
|
+
getSolanaNativeBalance(address?: string): Promise<string>;
|
|
226
|
+
/**
|
|
227
|
+
* Fetch a single ERC-20 token balance on Ethereum.
|
|
228
|
+
*
|
|
229
|
+
* Efficient method for checking a specific token balance (1 RPC call).
|
|
230
|
+
* Use `fetchEthereumWalletAllBalances()` for complete portfolio view.
|
|
231
|
+
*
|
|
232
|
+
* @param symbol - Token symbol (GALA, GWETH, GUSDC, GUSDT, GWTRX, GWBTC)
|
|
233
|
+
* @param address - Ethereum address (0x format). Defaults to configured wallet.
|
|
234
|
+
* @returns Single token balance with metadata
|
|
235
|
+
* @throws Error if Ethereum bridge not configured or invalid symbol
|
|
236
|
+
*
|
|
237
|
+
* @example
|
|
238
|
+
* ```typescript
|
|
239
|
+
* // Check GALA balance on Ethereum
|
|
240
|
+
* const gala = await bridgeService.fetchEthereumWalletTokenBalance('GALA');
|
|
241
|
+
* console.log(`GALA: ${gala.quantity}`);
|
|
242
|
+
*
|
|
243
|
+
* // Check specific address
|
|
244
|
+
* const gusdc = await bridgeService.fetchEthereumWalletTokenBalance('GUSDC', '0x1234...');
|
|
245
|
+
* ```
|
|
246
|
+
*/
|
|
247
|
+
fetchEthereumWalletTokenBalance(symbol: string, address?: string): Promise<ExternalChainBalance>;
|
|
248
|
+
/**
|
|
249
|
+
* Fetch native ETH balance on Ethereum.
|
|
250
|
+
*
|
|
251
|
+
* Efficient method for checking ETH balance only (1 RPC call).
|
|
252
|
+
* Use `fetchEthereumWalletAllBalances()` for complete portfolio view.
|
|
253
|
+
*
|
|
254
|
+
* @param address - Ethereum address (0x format). Defaults to configured wallet.
|
|
255
|
+
* @returns Native ETH balance with metadata
|
|
256
|
+
* @throws Error if Ethereum bridge not configured
|
|
257
|
+
*
|
|
258
|
+
* @example
|
|
259
|
+
* ```typescript
|
|
260
|
+
* // Check ETH balance (for gas fees)
|
|
261
|
+
* const eth = await bridgeService.fetchEthereumWalletNativeBalance();
|
|
262
|
+
* console.log(`ETH: ${eth.quantity}`);
|
|
263
|
+
* ```
|
|
264
|
+
*/
|
|
265
|
+
fetchEthereumWalletNativeBalance(address?: string): Promise<ExternalChainBalance>;
|
|
266
|
+
/**
|
|
267
|
+
* Fetch a single SPL token balance on Solana.
|
|
268
|
+
*
|
|
269
|
+
* Efficient method for checking a specific token balance (1 RPC call).
|
|
270
|
+
* Use `fetchSolanaWalletAllBalances()` for complete portfolio view.
|
|
271
|
+
*
|
|
272
|
+
* @param symbol - Token symbol (GALA, GSOL)
|
|
273
|
+
* @param address - Solana address (base58 format). Defaults to configured wallet.
|
|
274
|
+
* @returns Single token balance with metadata
|
|
275
|
+
* @throws Error if Solana bridge not configured or invalid symbol
|
|
276
|
+
*
|
|
277
|
+
* @example
|
|
278
|
+
* ```typescript
|
|
279
|
+
* // Check GALA balance on Solana
|
|
280
|
+
* const gala = await bridgeService.fetchSolanaWalletTokenBalance('GALA');
|
|
281
|
+
* console.log(`GALA: ${gala.quantity}`);
|
|
282
|
+
* ```
|
|
283
|
+
*/
|
|
284
|
+
fetchSolanaWalletTokenBalance(symbol: string, address?: string): Promise<ExternalChainBalance>;
|
|
285
|
+
/**
|
|
286
|
+
* Fetch native SOL balance on Solana.
|
|
287
|
+
*
|
|
288
|
+
* Efficient method for checking SOL balance only (1 RPC call).
|
|
289
|
+
* Use `fetchSolanaWalletAllBalances()` for complete portfolio view.
|
|
290
|
+
*
|
|
291
|
+
* @param address - Solana address (base58 format). Defaults to configured wallet.
|
|
292
|
+
* @returns Native SOL balance with metadata
|
|
293
|
+
* @throws Error if Solana bridge not configured
|
|
294
|
+
*
|
|
295
|
+
* @example
|
|
296
|
+
* ```typescript
|
|
297
|
+
* // Check SOL balance (for transaction fees)
|
|
298
|
+
* const sol = await bridgeService.fetchSolanaWalletNativeBalance();
|
|
299
|
+
* console.log(`SOL: ${sol.quantity}`);
|
|
300
|
+
* ```
|
|
301
|
+
*/
|
|
302
|
+
fetchSolanaWalletNativeBalance(address?: string): Promise<ExternalChainBalance>;
|
|
303
|
+
/**
|
|
304
|
+
* Fetch all supported token balances on Ethereum for a wallet.
|
|
305
|
+
*
|
|
306
|
+
* Returns native ETH balance plus all supported ERC-20 token balances:
|
|
307
|
+
* GALA, GWETH, GUSDC, GUSDT, GWTRX, GWBTC
|
|
308
|
+
*
|
|
309
|
+
* For checking a single token, use `fetchEthereumWalletTokenBalance()` (more efficient).
|
|
310
|
+
*
|
|
311
|
+
* @param address - Ethereum address (0x format). Defaults to configured wallet.
|
|
312
|
+
* @returns Complete balance breakdown for all supported tokens
|
|
313
|
+
* @throws Error if Ethereum bridge not configured
|
|
314
|
+
*
|
|
315
|
+
* @example
|
|
316
|
+
* ```typescript
|
|
317
|
+
* // Get all Ethereum balances
|
|
318
|
+
* const result = await bridgeService.fetchEthereumWalletAllBalances();
|
|
319
|
+
* console.log(`ETH: ${result.native.quantity}`);
|
|
320
|
+
* for (const token of result.tokens) {
|
|
321
|
+
* console.log(`${token.symbol}: ${token.quantity}`);
|
|
322
|
+
* }
|
|
323
|
+
*
|
|
324
|
+
* // Check specific address
|
|
325
|
+
* const otherWallet = await bridgeService.fetchEthereumWalletAllBalances('0x1234...');
|
|
326
|
+
* ```
|
|
327
|
+
*/
|
|
328
|
+
fetchEthereumWalletAllBalances(address?: string): Promise<EthereumWalletBalanceResult>;
|
|
329
|
+
/**
|
|
330
|
+
* Fetch all supported token balances on Solana for a wallet.
|
|
331
|
+
*
|
|
332
|
+
* Returns native SOL balance plus all supported SPL token balances:
|
|
333
|
+
* GALA, GSOL
|
|
334
|
+
*
|
|
335
|
+
* For checking a single token, use `fetchSolanaWalletTokenBalance()` (more efficient).
|
|
336
|
+
*
|
|
337
|
+
* @param address - Solana address (base58 format). Defaults to configured wallet.
|
|
338
|
+
* @returns Complete balance breakdown for all supported tokens
|
|
339
|
+
* @throws Error if Solana bridge not configured
|
|
340
|
+
*
|
|
341
|
+
* @example
|
|
342
|
+
* ```typescript
|
|
343
|
+
* // Get all Solana balances
|
|
344
|
+
* const result = await bridgeService.fetchSolanaWalletAllBalances();
|
|
345
|
+
* console.log(`SOL: ${result.native.quantity}`);
|
|
346
|
+
* for (const token of result.tokens) {
|
|
347
|
+
* console.log(`${token.symbol}: ${token.quantity}`);
|
|
348
|
+
* }
|
|
349
|
+
*
|
|
350
|
+
* // Check specific address
|
|
351
|
+
* const otherWallet = await bridgeService.fetchSolanaWalletAllBalances('9WzDXw...');
|
|
352
|
+
* ```
|
|
353
|
+
*/
|
|
354
|
+
fetchSolanaWalletAllBalances(address?: string): Promise<SolanaWalletBalanceResult>;
|
|
355
|
+
/**
|
|
356
|
+
* Get the strategy for a specific chain.
|
|
357
|
+
*
|
|
358
|
+
* @param chain - Target chain
|
|
359
|
+
* @returns Bridge strategy
|
|
360
|
+
* @throws Error if chain is not supported
|
|
361
|
+
*/
|
|
362
|
+
private getStrategy;
|
|
363
|
+
}
|
|
364
|
+
//# sourceMappingURL=BridgeService.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"BridgeService.d.ts","sourceRoot":"","sources":["../../../src/bridge/BridgeService.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAYH,OAAO,KAAK,EACV,YAAY,EACZ,iBAAiB,EACjB,cAAc,EACd,eAAe,EACf,YAAY,EACZ,WAAW,EACX,iBAAiB,EACjB,eAAe,EACf,oBAAoB,EACpB,oBAAoB,EACpB,2BAA2B,EAC3B,yBAAyB,EAC1B,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAIL,KAAK,iBAAiB,EACvB,MAAM,sBAAsB,CAAC;AAO9B,YAAY,EAAE,iBAAiB,EAAE,CAAC;AAElC;;GAEG;AACH,MAAM,WAAW,mBAAoB,SAAQ,YAAY;IACvD,2CAA2C;IAC3C,sBAAsB,EAAE,MAAM,CAAC;IAC/B,qEAAqE;IACrE,kBAAkB,EAAE,MAAM,CAAC;IAC3B,qFAAqF;IACrF,WAAW,CAAC,EAAE,iBAAiB,CAAC;CACjC;AAoCD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AACH,qBAAa,aAAa;IACxB,OAAO,CAAC,QAAQ,CAAC,MAAM,CAA8B;IACrD,OAAO,CAAC,QAAQ,CAAC,iBAAiB,CAAoB;IACtD,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAuC;IAElE;;;;;;;;;;;;O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
+
* Handles authentication, rate limiting, and bridge-specific endpoints.
|
|
6
|
+
*
|
|
7
|
+
* Based on the proven implementation from bridge_round_trip repository.
|
|
8
|
+
*/
|
|
9
|
+
import type { BridgeTokenDescriptor, BridgeConfigurationToken, BridgeFeeResponse, RequestBridgeOutResponse, BridgeTokenOutResponse, BridgeStatusResponse, BridgeTransactionRegistrationResponse, FetchBalancesResponse, GalaConnectConfig } from './types/index.js';
|
|
10
|
+
/**
|
|
11
|
+
* HTTP error from GalaConnect API.
|
|
12
|
+
*/
|
|
13
|
+
export declare class GalaConnectHttpError extends Error {
|
|
14
|
+
readonly status: number;
|
|
15
|
+
readonly path: string;
|
|
16
|
+
readonly responseBody: unknown;
|
|
17
|
+
/**
|
|
18
|
+
* Creates a new GalaConnect HTTP error.
|
|
19
|
+
*
|
|
20
|
+
* @param status - HTTP status code
|
|
21
|
+
* @param path - API endpoint path
|
|
22
|
+
* @param responseBody - Response body (may contain error details)
|
|
23
|
+
*/
|
|
24
|
+
constructor(status: number, path: string, responseBody: unknown);
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* GalaConnect Bridge API Client.
|
|
28
|
+
*
|
|
29
|
+
* Provides type-safe access to the GalaConnect bridge endpoints:
|
|
30
|
+
* - Bridge configuration discovery
|
|
31
|
+
* - Fee estimation
|
|
32
|
+
* - Bridge out (GalaChain → External)
|
|
33
|
+
* - Bridge in (External → GalaChain)
|
|
34
|
+
* - Status tracking
|
|
35
|
+
*
|
|
36
|
+
* @example
|
|
37
|
+
* ```typescript
|
|
38
|
+
* const client = new GalaConnectClient({
|
|
39
|
+
* walletAddress: 'eth|0x1234...',
|
|
40
|
+
* // Uses GALACONNECT_PRODUCTION_URL by default
|
|
41
|
+
* });
|
|
42
|
+
*
|
|
43
|
+
* // Get supported tokens
|
|
44
|
+
* const tokens = await client.getBridgeConfigurations('GALA');
|
|
45
|
+
*
|
|
46
|
+
* // Estimate fees
|
|
47
|
+
* const fee = await client.fetchBridgeFee({
|
|
48
|
+
* chainId: '1',
|
|
49
|
+
* bridgeToken: { collection: 'GALA', category: 'Unit', type: 'none', additionalKey: 'none' }
|
|
50
|
+
* });
|
|
51
|
+
* ```
|
|
52
|
+
*/
|
|
53
|
+
export declare class GalaConnectClient {
|
|
54
|
+
private readonly baseUrl;
|
|
55
|
+
private readonly galachainBaseUrl;
|
|
56
|
+
private readonly walletAddress;
|
|
57
|
+
private readonly rateLimiter;
|
|
58
|
+
private readonly defaultHeaders;
|
|
59
|
+
private readonly retryOptions;
|
|
60
|
+
/**
|
|
61
|
+
* Creates a new GalaConnect client.
|
|
62
|
+
*
|
|
63
|
+
* @param config - Client configuration
|
|
64
|
+
*/
|
|
65
|
+
constructor(config: GalaConnectConfig);
|
|
66
|
+
/**
|
|
67
|
+
* Get bridge configurations for tokens matching a prefix.
|
|
68
|
+
*
|
|
69
|
+
* Returns detailed token information including:
|
|
70
|
+
* - Token class key (collection, category, type, additionalKey)
|
|
71
|
+
* - Supported bridge routes
|
|
72
|
+
* - External network contract addresses
|
|
73
|
+
*
|
|
74
|
+
* @param searchPrefix - Token symbol prefix to search (e.g., 'GALA', 'GUS')
|
|
75
|
+
* @returns Array of matching token configurations
|
|
76
|
+
*/
|
|
77
|
+
getBridgeConfigurations(searchPrefix: string): Promise<BridgeConfigurationToken[]>;
|
|
78
|
+
/**
|
|
79
|
+
* Fetch bridge fee estimate for a token transfer.
|
|
80
|
+
*
|
|
81
|
+
* @param payload - Fee request parameters
|
|
82
|
+
* @returns Fee estimate with breakdown
|
|
83
|
+
*/
|
|
84
|
+
fetchBridgeFee(payload: {
|
|
85
|
+
chainId: string;
|
|
86
|
+
bridgeToken: BridgeTokenDescriptor;
|
|
87
|
+
}): Promise<BridgeFeeResponse>;
|
|
88
|
+
/**
|
|
89
|
+
* Request token bridge out (initiate GalaChain → External transfer).
|
|
90
|
+
*
|
|
91
|
+
* This is the first step in the bridge out process:
|
|
92
|
+
* 1. RequestBridgeOut - Lock tokens on GalaChain
|
|
93
|
+
* 2. BridgeTokenOut - Generate wormhole message
|
|
94
|
+
*
|
|
95
|
+
* @param payload - Bridge out request parameters
|
|
96
|
+
* @returns Response with transaction data
|
|
97
|
+
*/
|
|
98
|
+
requestBridgeOut(payload: Record<string, unknown>): Promise<RequestBridgeOutResponse>;
|
|
99
|
+
/**
|
|
100
|
+
* Execute bridge token out (generate wormhole message).
|
|
101
|
+
*
|
|
102
|
+
* This is the second step in the bridge out process.
|
|
103
|
+
* Called after RequestBridgeOut succeeds.
|
|
104
|
+
*
|
|
105
|
+
* @param payload - Bridge token out parameters
|
|
106
|
+
* @returns Response with wormhole message data
|
|
107
|
+
*/
|
|
108
|
+
bridgeTokenOut(payload: Record<string, unknown>): Promise<BridgeTokenOutResponse>;
|
|
109
|
+
/**
|
|
110
|
+
* Get the status of a bridge transaction.
|
|
111
|
+
*
|
|
112
|
+
* @param hash - Transaction hash to check
|
|
113
|
+
* @returns Current status with details
|
|
114
|
+
*/
|
|
115
|
+
getBridgeStatus(hash: string): Promise<BridgeStatusResponse>;
|
|
116
|
+
/**
|
|
117
|
+
* Register a bridge transaction (for External → GalaChain transfers).
|
|
118
|
+
*
|
|
119
|
+
* Called after depositing tokens to the bridge contract on the external chain.
|
|
120
|
+
* Notifies GalaConnect to process the inbound transfer.
|
|
121
|
+
*
|
|
122
|
+
* @param payload - Transaction registration data
|
|
123
|
+
* @returns Registration response
|
|
124
|
+
*/
|
|
125
|
+
registerBridgeTransaction(payload: Record<string, unknown>): Promise<BridgeTransactionRegistrationResponse>;
|
|
126
|
+
/**
|
|
127
|
+
* Fetch token balances for the wallet.
|
|
128
|
+
*
|
|
129
|
+
* @param channel - Token channel (default: 'asset')
|
|
130
|
+
* @returns Balance response with token holdings
|
|
131
|
+
*/
|
|
132
|
+
fetchBalances(channel?: string): Promise<FetchBalancesResponse>;
|
|
133
|
+
/**
|
|
134
|
+
* Make a POST request with JSON body.
|
|
135
|
+
*
|
|
136
|
+
* @param path - API endpoint path
|
|
137
|
+
* @param body - Request body
|
|
138
|
+
* @param options - Request options (baseUrl override, skipWalletHeader)
|
|
139
|
+
* @returns Parsed JSON response
|
|
140
|
+
*/
|
|
141
|
+
private postJson;
|
|
142
|
+
/**
|
|
143
|
+
* Make a rate-limited HTTP request with optional retry logic.
|
|
144
|
+
*
|
|
145
|
+
* Retry behavior (when enabled):
|
|
146
|
+
* - Retries on network errors (ECONNRESET, ETIMEDOUT, etc.)
|
|
147
|
+
* - Retries on server errors (5xx status codes)
|
|
148
|
+
* - Retries on rate limiting (429 Too Many Requests)
|
|
149
|
+
* - Uses exponential backoff with jitter
|
|
150
|
+
*
|
|
151
|
+
* @param url - Full URL to request
|
|
152
|
+
* @param init - Fetch init options
|
|
153
|
+
* @returns Fetch response
|
|
154
|
+
*/
|
|
155
|
+
private request;
|
|
156
|
+
/**
|
|
157
|
+
* Safely parse JSON from a response (for error handling).
|
|
158
|
+
*
|
|
159
|
+
* @param response - Fetch response
|
|
160
|
+
* @returns Parsed JSON or raw text
|
|
161
|
+
*/
|
|
162
|
+
private safeParseJson;
|
|
163
|
+
}
|
|
164
|
+
//# sourceMappingURL=GalaConnectClient.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"GalaConnectClient.d.ts","sourceRoot":"","sources":["../../../src/bridge/GalaConnectClient.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EACV,qBAAqB,EACrB,wBAAwB,EACxB,iBAAiB,EACjB,wBAAwB,EACxB,sBAAsB,EACtB,oBAAoB,EACpB,qCAAqC,EACrC,qBAAqB,EACrB,iBAAiB,EAClB,MAAM,kBAAkB,CAAC;AAI1B;;GAEG;AACH,qBAAa,oBAAqB,SAAQ,KAAK;aAS3B,MAAM,EAAE,MAAM;aACd,IAAI,EAAE,MAAM;aACZ,YAAY,EAAE,OAAO;IAVvC;;;;;;OAMG;gBAEe,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,MAAM,EACZ,YAAY,EAAE,OAA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