@gala-chain/launchpad-sdk 4.0.7-beta.3 → 4.0.7-beta.7

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.
Files changed (44) hide show
  1. package/README.md +144 -0
  2. package/dist/index.cjs.js +1 -1
  3. package/dist/index.d.ts +2 -0
  4. package/dist/index.d.ts.map +1 -1
  5. package/dist/index.esm.js +1 -1
  6. package/dist/index.js +1 -1
  7. package/dist/src/LaunchpadSDK.d.ts +150 -0
  8. package/dist/src/LaunchpadSDK.d.ts.map +1 -1
  9. package/dist/src/bridge/BridgeService.d.ts +343 -0
  10. package/dist/src/bridge/BridgeService.d.ts.map +1 -0
  11. package/dist/src/bridge/GalaConnectClient.d.ts +164 -0
  12. package/dist/src/bridge/GalaConnectClient.d.ts.map +1 -0
  13. package/dist/src/bridge/constants/index.d.ts +7 -0
  14. package/dist/src/bridge/constants/index.d.ts.map +1 -0
  15. package/dist/src/bridge/constants/tokens.d.ts +181 -0
  16. package/dist/src/bridge/constants/tokens.d.ts.map +1 -0
  17. package/dist/src/bridge/index.d.ts +22 -0
  18. package/dist/src/bridge/index.d.ts.map +1 -0
  19. package/dist/src/bridge/strategies/BridgeStrategy.d.ts +160 -0
  20. package/dist/src/bridge/strategies/BridgeStrategy.d.ts.map +1 -0
  21. package/dist/src/bridge/strategies/EthereumBridgeStrategy.d.ts +198 -0
  22. package/dist/src/bridge/strategies/EthereumBridgeStrategy.d.ts.map +1 -0
  23. package/dist/src/bridge/strategies/SolanaBridgeStrategy.d.ts +207 -0
  24. package/dist/src/bridge/strategies/SolanaBridgeStrategy.d.ts.map +1 -0
  25. package/dist/src/bridge/strategies/index.d.ts +9 -0
  26. package/dist/src/bridge/strategies/index.d.ts.map +1 -0
  27. package/dist/src/bridge/types/bridge.dto.d.ts +612 -0
  28. package/dist/src/bridge/types/bridge.dto.d.ts.map +1 -0
  29. package/dist/src/bridge/types/eip712.d.ts +57 -0
  30. package/dist/src/bridge/types/eip712.d.ts.map +1 -0
  31. package/dist/src/bridge/types/index.d.ts +8 -0
  32. package/dist/src/bridge/types/index.d.ts.map +1 -0
  33. package/dist/src/bridge/utils/RateLimiter.d.ts +34 -0
  34. package/dist/src/bridge/utils/RateLimiter.d.ts.map +1 -0
  35. package/dist/src/bridge/utils/index.d.ts +9 -0
  36. package/dist/src/bridge/utils/index.d.ts.map +1 -0
  37. package/dist/src/bridge/utils/retry.d.ts +96 -0
  38. package/dist/src/bridge/utils/retry.d.ts.map +1 -0
  39. package/dist/src/bridge/utils/tokenMath.d.ts +39 -0
  40. package/dist/src/bridge/utils/tokenMath.d.ts.map +1 -0
  41. package/dist/src/constants/version.generated.d.ts +1 -1
  42. package/dist/src/index.d.ts +2 -0
  43. package/dist/src/index.d.ts.map +1 -1
  44. package/package.json +19 -2
@@ -0,0 +1,164 @@
1
+ /**
2
+ * GalaConnect Bridge Client
3
+ *
4
+ * HTTP client for GalaConnect Bridge API interactions.
5
+ * 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,OAAO;CASxC;AAcD;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,qBAAa,iBAAiB;IAC5B,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAS;IACjC,OAAO,CAAC,QAAQ,CAAC,gBAAgB,CAAS;IAC1C,OAAO,CAAC,QAAQ,CAAC,aAAa,CAAS;IACvC,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAc;IAC1C,OAAO,CAAC,QAAQ,CAAC,cAAc,CAAyB;IACxD,OAAO,CAAC,QAAQ,CAAC,YAAY,CAAsB;IAEnD;;;;OAIG;gBACS,MAAM,EAAE,iBAAiB;IAoCrC;;;;;;;;;;OAUG;IACG,uBAAuB,CAC3B,YAAY,EAAE,MAAM,GACnB,OAAO,CAAC,wBAAwB,EAAE,CAAC;IAqBtC;;;;;OAKG;IACG,cAAc,CAAC,OAAO,EAAE;QAC5B,OAAO,EAAE,MAAM,CAAC;QAChB,WAAW,EAAE,qBAAqB,CAAC;KACpC,GAAG,OAAO,CAAC,iBAAiB,CAAC;IAQ9B;;;;;;;;;OASG;IACG,gBAAgB,CACpB,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAC/B,OAAO,CAAC,wBAAwB,CAAC;IAOpC;;;;;;;;OAQG;IACG,cAAc,CAClB,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAC/B,OAAO,CAAC,sBAAsB,CAAC;IAIlC;;;;;OAKG;IACG,eAAe,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,oBAAoB,CAAC;IAIlE;;;;;;;;OAQG;IACG,yBAAyB,CAC7B,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAC/B,OAAO,CAAC,qCAAqC,CAAC;IAOjD;;;;;OAKG;IACG,aAAa,CAAC,OAAO,SAAU,GAAG,OAAO,CAAC,qBAAqB,CAAC;IAQtE;;;;;;;OAOG;YACW,QAAQ;IAoDtB;;;;;;;;;;;;OAYG;YACW,OAAO;IA+CrB;;;;;OAKG;YACW,aAAa;CAQ5B"}
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Bridge Constants Index
3
+ *
4
+ * Re-exports all bridge-related constants.
5
+ */
6
+ export * from './tokens.js';
7
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/bridge/constants/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,cAAc,aAAa,CAAC"}
@@ -0,0 +1,181 @@
1
+ /**
2
+ * Bridge Token Constants
3
+ *
4
+ * Static token configurations and chain IDs for bridging.
5
+ */
6
+ import type { EthereumTokenConfig, SolanaTokenConfig, TokenMetadata, BridgeTokenDescriptor } from '../types/bridge.dto.js';
7
+ /**
8
+ * Chain IDs used by the bridge system
9
+ */
10
+ export declare const CHAIN_IDS: {
11
+ readonly GALA_CHAIN: 1;
12
+ readonly ETHEREUM: 2;
13
+ readonly SOLANA: 1002;
14
+ };
15
+ /**
16
+ * Rate limit for GalaConnect API (requests per second)
17
+ */
18
+ export declare const DEFAULT_RATE_LIMIT_RPS = 12;
19
+ /**
20
+ * Default polling interval for bridge status (15 seconds)
21
+ */
22
+ export declare const DEFAULT_POLL_INTERVAL_MS = 15000;
23
+ /**
24
+ * Default polling timeout (45 minutes)
25
+ */
26
+ export declare const DEFAULT_POLL_TIMEOUT_MS: number;
27
+ /**
28
+ * Delay before registering inbound bridge transactions (30 seconds)
29
+ */
30
+ export declare const REGISTRATION_DELAY_MS = 30000;
31
+ /**
32
+ * Solana compute budget settings
33
+ */
34
+ export declare const SOLANA_COMPUTE: {
35
+ readonly UNIT_LIMIT: 200000;
36
+ readonly UNIT_PRICE_MICROLAMPORTS: 375000;
37
+ };
38
+ /**
39
+ * Default Ethereum RPC URL (public endpoint)
40
+ *
41
+ * **WARNING: Public RPC Endpoint Limitations**
42
+ *
43
+ * This is a free public endpoint with the following limitations:
44
+ * - **Rate Limits**: Typically 10-25 requests/second (varies by provider load)
45
+ * - **Reliability**: No SLA, may experience downtime during high network activity
46
+ * - **Privacy**: Requests may be logged by the provider
47
+ * - **Features**: May not support all RPC methods (e.g., trace_* calls)
48
+ * - **Monitoring**: No error tracking, request analytics, or debugging tools available
49
+ *
50
+ * **For Production Use**, provide your own RPC URL from:
51
+ * - Infura: https://infura.io (free tier: 100k requests/day)
52
+ * - Alchemy: https://alchemy.com (free tier: 300M compute units/month)
53
+ * - QuickNode: https://quicknode.com
54
+ * - Your own Ethereum node
55
+ *
56
+ * @example
57
+ * ```typescript
58
+ * const bridgeService = new BridgeService({
59
+ * ethereumRpcUrl: 'https://mainnet.infura.io/v3/YOUR_API_KEY',
60
+ * // ... other config
61
+ * });
62
+ * ```
63
+ */
64
+ export declare const DEFAULT_ETHEREUM_RPC_URL = "https://ethereum.publicnode.com";
65
+ /**
66
+ * Default Solana RPC URL (public endpoint)
67
+ *
68
+ * **WARNING: Public RPC Endpoint Limitations**
69
+ *
70
+ * This is the official Solana public RPC with the following limitations:
71
+ * - **Rate Limits**: Aggressive rate limiting (may return 429 errors under load)
72
+ * - **Reliability**: Best-effort availability, no SLA
73
+ * - **Performance**: Higher latency than dedicated endpoints
74
+ * - **Features**: Some methods may be disabled or limited
75
+ * - **Monitoring**: No error tracking, request analytics, or debugging tools available
76
+ *
77
+ * **For Production Use**, provide your own RPC URL from:
78
+ * - Helius: https://helius.dev (free tier: 500k credits/month)
79
+ * - QuickNode: https://quicknode.com
80
+ * - Triton: https://triton.one
81
+ * - Your own Solana validator
82
+ *
83
+ * @example
84
+ * ```typescript
85
+ * const bridgeService = new BridgeService({
86
+ * solanaRpcUrl: 'https://mainnet.helius-rpc.com/?api-key=YOUR_API_KEY',
87
+ * // ... other config
88
+ * });
89
+ * ```
90
+ */
91
+ export declare const DEFAULT_SOLANA_RPC_URL = "https://api.mainnet-beta.solana.com";
92
+ /**
93
+ * Default Ethereum bridge contract address (mainnet)
94
+ */
95
+ export declare const DEFAULT_ETHEREUM_BRIDGE_CONTRACT = "0x9f452b7cC24e6e6FA690fe77CF5dD2ba3DbF1ED9";
96
+ /**
97
+ * Ethereum bridge contract address for Sepolia testnet
98
+ */
99
+ export declare const ETHEREUM_BRIDGE_CONTRACT_SEPOLIA = "0x6a1734E09f3099a3675645D214ce547080ea67e0";
100
+ /**
101
+ * Default Solana bridge program ID (mainnet)
102
+ */
103
+ export declare const DEFAULT_SOLANA_BRIDGE_PROGRAM = "AaE4dTnL75XqgUJpdxBKg6vS9sTJgBPJwBQRVhD29WwS";
104
+ /**
105
+ * GalaConnect production base URL (DEX API platform)
106
+ */
107
+ export declare const GALACONNECT_PRODUCTION_URL = "https://dex-api-platform-dex-prod-gala.gala.com";
108
+ /**
109
+ * Ethereum tokens for bridging - Production (Mainnet)
110
+ */
111
+ export declare const ETHEREUM_TOKENS_PROD: EthereumTokenConfig[];
112
+ /**
113
+ * Ethereum tokens for bridging - Stage (Sepolia testnet)
114
+ *
115
+ * Note: GWTRX is not available on Sepolia
116
+ */
117
+ export declare const ETHEREUM_TOKENS_STAGE: EthereumTokenConfig[];
118
+ /** Bridge environment type for token selection */
119
+ export type BridgeEnvironment = 'PROD' | 'STAGE';
120
+ /**
121
+ * Get Ethereum tokens by environment
122
+ *
123
+ * @param environment - Target environment (PROD or STAGE)
124
+ * @returns Token configurations for the specified environment
125
+ */
126
+ export declare function getEthereumTokensByEnvironment(environment: BridgeEnvironment): EthereumTokenConfig[];
127
+ /**
128
+ * Get Ethereum bridge contract address by environment
129
+ *
130
+ * @param environment - Target environment (PROD or STAGE)
131
+ * @returns Bridge contract address for the specified environment
132
+ */
133
+ export declare function getEthereumBridgeContractByEnvironment(environment: BridgeEnvironment): string;
134
+ /**
135
+ * Default supported Ethereum tokens for bridging (Production/Mainnet)
136
+ *
137
+ * @deprecated Use `getEthereumTokensByEnvironment()` for environment-aware token selection
138
+ */
139
+ export declare const DEFAULT_ETHEREUM_TOKENS: EthereumTokenConfig[];
140
+ /**
141
+ * Default supported Solana tokens for bridging
142
+ */
143
+ export declare const DEFAULT_SOLANA_TOKENS: SolanaTokenConfig[];
144
+ /**
145
+ * Static token metadata for common bridge tokens
146
+ *
147
+ * This avoids API calls for well-known tokens.
148
+ */
149
+ export declare const STATIC_TOKEN_METADATA: Record<string, TokenMetadata>;
150
+ /**
151
+ * Ethereum ERC-20 ABI for bridge operations
152
+ */
153
+ export declare const ERC20_ABI: readonly ["function decimals() view returns (uint8)", "function balanceOf(address owner) view returns (uint256)", "function approve(address spender, uint256 value) returns (bool)", "function allowance(address owner, address spender) view returns (uint256)", "function transfer(address to, uint256 value) returns (bool)", "function name() view returns (string)", "function nonces(address owner) view returns (uint256)", "function permit(address owner,address spender,uint256 value,uint256 deadline,uint8 v,bytes32 r,bytes32 s)"];
154
+ /**
155
+ * Ethereum bridge contract ABI
156
+ */
157
+ export declare const BRIDGE_CONTRACT_ABI: readonly ["function bridgeOut(address token,uint256 amount,uint256 tokenId,uint16 destinationChainId,bytes recipient) external", "function bridgeOutWithPermit(address token,uint256 amount,uint16 destinationChainId,bytes recipient,uint256 deadline,uint8 v,bytes32 r,bytes32 s) external"];
158
+ /**
159
+ * Solana bridge instruction discriminators
160
+ */
161
+ export declare const SOLANA_DISCRIMINATORS: {
162
+ readonly BRIDGE_OUT: Buffer<ArrayBuffer>;
163
+ readonly BRIDGE_OUT_NATIVE: Buffer<ArrayBuffer>;
164
+ };
165
+ /**
166
+ * Get token metadata by symbol
167
+ */
168
+ export declare function getStaticTokenMetadata(symbol: string): TokenMetadata | undefined;
169
+ /**
170
+ * Get Ethereum token config by symbol
171
+ */
172
+ export declare function getEthereumTokenConfig(symbol: string): EthereumTokenConfig | undefined;
173
+ /**
174
+ * Get Solana token config by symbol
175
+ */
176
+ export declare function getSolanaTokenConfig(symbol: string): SolanaTokenConfig | undefined;
177
+ /**
178
+ * Format a BridgeTokenDescriptor as a pipe-separated string
179
+ */
180
+ export declare function formatTokenDescriptor(descriptor: BridgeTokenDescriptor): string;
181
+ //# sourceMappingURL=tokens.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tokens.d.ts","sourceRoot":"","sources":["../../../../src/bridge/constants/tokens.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EACV,mBAAmB,EACnB,iBAAiB,EACjB,aAAa,EACb,qBAAqB,EACtB,MAAM,wBAAwB,CAAC;AAEhC;;GAEG;AACH,eAAO,MAAM,SAAS;;;;CAIZ,CAAC;AAEX;;GAEG;AACH,eAAO,MAAM,sBAAsB,KAAK,CAAC;AAEzC;;GAEG;AACH,eAAO,MAAM,wBAAwB,QAAS,CAAC;AAE/C;;GAEG;AACH,eAAO,MAAM,uBAAuB,QAAkB,CAAC;AAEvD;;GAEG;AACH,eAAO,MAAM,qBAAqB,QAAS,CAAC;AAE5C;;GAEG;AACH,eAAO,MAAM,cAAc;;;CAGjB,CAAC;AAEX;;;;;;;;;;;;;;;;;;;;;;;;;G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BAAsB,CAAC,MAAM,EAAE,MAAM,GAAG,mBAAmB,GAAG,SAAS,CAKtF;AAED;;GAEG;AACH,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,MAAM,GAAG,iBAAiB,GAAG,SAAS,CAKlF;AAED;;GAEG;AACH,wBAAgB,qBAAqB,CAAC,UAAU,EAAE,qBAAqB,GAAG,MAAM,CAE/E"}
@@ -0,0 +1,22 @@
1
+ /**
2
+ * Bridge Module
3
+ *
4
+ * Cross-chain bridging capabilities for GalaChain.
5
+ * Supports bridging between:
6
+ * - GalaChain ↔ Ethereum (6 tokens)
7
+ * - GalaChain ↔ Solana (2 tokens)
8
+ *
9
+ * @module bridge
10
+ */
11
+ export { BridgeService, type BridgeServiceConfig, type BridgeEnvironment } from './BridgeService.js';
12
+ export { GalaConnectClient, GalaConnectHttpError } from './GalaConnectClient.js';
13
+ export { type BridgeStrategy, BaseBridgeStrategy, type WaitOptions, } from './strategies/BridgeStrategy.js';
14
+ export { EthereumBridgeStrategy, type EthereumBridgeConfig, } from './strategies/EthereumBridgeStrategy.js';
15
+ export { SolanaBridgeStrategy, type SolanaBridgeConfig, } from './strategies/SolanaBridgeStrategy.js';
16
+ export type { ExternalNetwork, BridgeTokenDescriptor, BridgeTokenInstance, EthereumTokenConfig, SolanaTokenConfig, BridgeConfigurationToken, TokenMetadata, ExternalTokenInfo, GalaExchangeRate, BaseTokenCrossRate, QuoteTokenCrossRate, GalaExchangeCrossRate, DestinationChainTxFee, BridgeFeeEstimate, BridgeRequestDto, BridgeStatus, BridgeTransaction, BridgeLegResult, TokenRoundTripResult, BridgeToken, BridgeConfig, EstimateBridgeFeeParams, BridgeOutParams, BridgeInParams, WaitForBridgeOptions, GalaConnectConfig, BridgeFeeResponse, RequestBridgeOutResponse, BridgeTokenOutResponse, BridgeStatusResponse, BridgeTransactionRegistrationResponse, TokenBalanceEntry, FetchBalancesResponse, ExternalChainBalance, EthereumWalletBalanceResult, SolanaWalletBalanceResult, } from './types/index.js';
17
+ export { BridgeStatusCode } from './types/index.js';
18
+ export { GALA_BRIDGE_TYPED_DATA_DOMAIN, LEGACY_TYPED_DATA_TYPES, CROSS_RATE_TYPED_DATA_TYPES, getGalaBridgeTypedDataTypes, } from './types/eip712.js';
19
+ export { CHAIN_IDS, DEFAULT_ETHEREUM_TOKENS, DEFAULT_SOLANA_TOKENS, STATIC_TOKEN_METADATA, ERC20_ABI, BRIDGE_CONTRACT_ABI, SOLANA_DISCRIMINATORS, GALACONNECT_PRODUCTION_URL, DEFAULT_RATE_LIMIT_RPS, DEFAULT_POLL_INTERVAL_MS, DEFAULT_POLL_TIMEOUT_MS, DEFAULT_ETHEREUM_RPC_URL, DEFAULT_SOLANA_RPC_URL, DEFAULT_ETHEREUM_BRIDGE_CONTRACT, ETHEREUM_BRIDGE_CONTRACT_SEPOLIA, DEFAULT_SOLANA_BRIDGE_PROGRAM, SOLANA_COMPUTE, ETHEREUM_TOKENS_PROD, ETHEREUM_TOKENS_STAGE, getEthereumTokensByEnvironment, getEthereumBridgeContractByEnvironment, getStaticTokenMetadata, getEthereumTokenConfig, getSolanaTokenConfig, formatTokenDescriptor, } from './constants/index.js';
20
+ export { RateLimiter } from './utils/RateLimiter.js';
21
+ export { toBaseUnits, fromBaseUnits, formatTokenAmount, compareAmounts, } from './utils/tokenMath.js';
22
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/bridge/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAGH,OAAO,EAAE,aAAa,EAAE,KAAK,mBAAmB,EAAE,KAAK,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AAGrG,OAAO,EAAE,iBAAiB,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAGjF,OAAO,EACL,KAAK,cAAc,EACnB,kBAAkB,EAClB,KAAK,WAAW,GACjB,MAAM,gCAAgC,CAAC;AACxC,OAAO,EACL,sBAAsB,EACtB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M,wBAAwB,CAAC;AACrD,OAAO,EACL,WAAW,EACX,aAAa,EACb,iBAAiB,EACjB,cAAc,GACf,MAAM,sBAAsB,CAAC"}
@@ -0,0 +1,160 @@
1
+ /**
2
+ * Bridge Strategy Interface
3
+ *
4
+ * Defines the contract for chain-specific bridge implementations.
5
+ * Each external chain (Ethereum, Solana) implements this interface
6
+ * to handle its unique signing, transaction, and status tracking logic.
7
+ */
8
+ import { type BridgeFeeEstimate, type BridgeInParams, type BridgeOutParams, type BridgeStatus, type BridgeTransaction, type ExternalNetwork } from '../types/index.js';
9
+ /**
10
+ * Strategy interface for chain-specific bridge operations.
11
+ *
12
+ * The Bridge SDK uses the Strategy pattern to abstract chain-specific logic:
13
+ * - EthereumBridgeStrategy: Handles ERC-20 approvals, ethers.js signing
14
+ * - SolanaBridgeStrategy: Handles SPL token accounts, @solana/web3.js signing
15
+ *
16
+ * Each strategy encapsulates:
17
+ * - Fee estimation for the target chain
18
+ * - Outbound transfers (GalaChain → External)
19
+ * - Inbound transfers (External → GalaChain)
20
+ * - Status polling and transaction tracking
21
+ *
22
+ * @example
23
+ * ```typescript
24
+ * class EthereumBridgeStrategy implements BridgeStrategy {
25
+ * readonly network: ExternalNetwork = 'Ethereum';
26
+ *
27
+ * async estimateFee(tokenSymbol: string, amount: string): Promise<BridgeFeeEstimate> {
28
+ * // Ethereum-specific fee calculation
29
+ * }
30
+ * }
31
+ * ```
32
+ */
33
+ export interface BridgeStrategy {
34
+ /**
35
+ * The external network this strategy handles.
36
+ */
37
+ readonly network: ExternalNetwork;
38
+ /**
39
+ * Estimate bridge fees for a transfer.
40
+ *
41
+ * Calculates the total cost including:
42
+ * - Bridge protocol fee (paid to GalaChain)
43
+ * - Network gas fee (estimated)
44
+ * - Any chain-specific fees
45
+ *
46
+ * @param tokenSymbol - Token symbol (e.g., 'GALA', 'GUSDC')
47
+ * @param amount - Amount in decimal format (e.g., '100.5')
48
+ * @returns Fee estimate with breakdown
49
+ */
50
+ estimateFee(tokenSymbol: string, amount: string): Promise<BridgeFeeEstimate>;
51
+ /**
52
+ * Bridge tokens OUT from GalaChain to external chain.
53
+ *
54
+ * Flow:
55
+ * 1. Lock tokens on GalaChain (via GalaConnect)
56
+ * 2. Wait for bridge confirmation
57
+ * 3. Receive wrapped tokens on external chain
58
+ *
59
+ * @param params - Bridge out parameters
60
+ * @returns Transaction details with tracking info
61
+ */
62
+ bridgeOut(params: BridgeOutParams): Promise<BridgeTransaction>;
63
+ /**
64
+ * Bridge tokens IN from external chain to GalaChain.
65
+ *
66
+ * Flow:
67
+ * 1. Approve bridge contract (if needed)
68
+ * 2. Deposit tokens to bridge contract
69
+ * 3. Wait for GalaChain confirmation
70
+ * 4. Receive native tokens on GalaChain
71
+ *
72
+ * @param params - Bridge in parameters
73
+ * @returns Transaction details with tracking info
74
+ */
75
+ bridgeIn(params: BridgeInParams): Promise<BridgeTransaction>;
76
+ /**
77
+ * Get the current status of a bridge transaction.
78
+ *
79
+ * Polls both the source and destination chains to determine
80
+ * the transaction's progress through the bridge.
81
+ *
82
+ * @param transactionHash - The bridge transaction hash
83
+ * @returns Current status with details
84
+ */
85
+ getStatus(transactionHash: string): Promise<BridgeStatus>;
86
+ /**
87
+ * Wait for a bridge transaction to complete.
88
+ *
89
+ * Polls the transaction status until it reaches a terminal state
90
+ * (completed or failed) or the timeout is reached.
91
+ *
92
+ * @param transactionHash - The bridge transaction hash
93
+ * @param options - Polling options
94
+ * @returns Final status when complete
95
+ * @throws Error if timeout reached or transaction fails
96
+ */
97
+ waitForCompletion(transactionHash: string, options?: WaitOptions): Promise<BridgeStatus>;
98
+ /**
99
+ * Get the list of supported tokens for this chain.
100
+ *
101
+ * @returns Array of token symbols supported by this bridge
102
+ */
103
+ getSupportedTokens(): string[];
104
+ /**
105
+ * Check if a specific token is supported for bridging.
106
+ *
107
+ * @param tokenSymbol - Token symbol to check
108
+ * @returns True if token can be bridged
109
+ */
110
+ isTokenSupported(tokenSymbol: string): boolean;
111
+ /**
112
+ * Validate a recipient address for the external chain.
113
+ *
114
+ * @param address - Address to validate
115
+ * @returns True if address is valid for this chain
116
+ */
117
+ isValidAddress(address: string): boolean;
118
+ }
119
+ /**
120
+ * Options for waiting on bridge completion.
121
+ */
122
+ export interface WaitOptions {
123
+ /**
124
+ * Polling interval in milliseconds.
125
+ * @default 15000 (15 seconds)
126
+ */
127
+ pollInterval?: number;
128
+ /**
129
+ * Maximum time to wait in milliseconds.
130
+ * @default 2700000 (45 minutes)
131
+ */
132
+ timeout?: number;
133
+ /**
134
+ * Callback for status updates during polling.
135
+ */
136
+ onStatusUpdate?: (status: BridgeStatus) => void;
137
+ }
138
+ /**
139
+ * Base class providing common functionality for bridge strategies.
140
+ *
141
+ * Concrete strategies extend this class and implement chain-specific logic.
142
+ */
143
+ export declare abstract class BaseBridgeStrategy implements BridgeStrategy {
144
+ abstract readonly network: ExternalNetwork;
145
+ abstract estimateFee(tokenSymbol: string, amount: string): Promise<BridgeFeeEstimate>;
146
+ abstract bridgeOut(params: BridgeOutParams): Promise<BridgeTransaction>;
147
+ abstract bridgeIn(params: BridgeInParams): Promise<BridgeTransaction>;
148
+ abstract getStatus(transactionHash: string): Promise<BridgeStatus>;
149
+ abstract getSupportedTokens(): string[];
150
+ abstract isTokenSupported(tokenSymbol: string): boolean;
151
+ abstract isValidAddress(address: string): boolean;
152
+ /**
153
+ * Default implementation of waitForCompletion with polling.
154
+ *
155
+ * Strategies can override this if they have chain-specific
156
+ * event subscription capabilities.
157
+ */
158
+ waitForCompletion(transactionHash: string, options?: WaitOptions): Promise<BridgeStatus>;
159
+ }
160
+ //# sourceMappingURL=BridgeStrategy.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"BridgeStrategy.d.ts","sourceRoot":"","sources":["../../../../src/bridge/strategies/BridgeStrategy.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAEL,KAAK,iBAAiB,EACtB,KAAK,cAAc,EACnB,KAAK,eAAe,EACpB,KAAK,YA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