@gala-chain/launchpad-sdk 0.4.3 → 3.0.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/README.md +358 -75
- package/dist/examples/complete-sdk-demo.d.ts +22 -0
- package/dist/examples/complete-sdk-demo.d.ts.map +1 -0
- package/dist/index.cjs.js +1 -1
- package/dist/index.esm.js +1 -1
- package/dist/index.js +1 -1
- package/dist/src/LaunchpadSDK.d.ts +755 -0
- package/dist/src/LaunchpadSDK.d.ts.map +1 -0
- package/dist/{api → src/api}/LaunchpadAPI.d.ts +101 -63
- package/dist/src/api/LaunchpadAPI.d.ts.map +1 -0
- package/dist/{api → src/api}/dto/BondingCurveDTOs.d.ts +8 -5
- package/dist/src/api/dto/BondingCurveDTOs.d.ts.map +1 -0
- package/dist/src/api/dto/TransferTokenDto.d.ts +76 -0
- package/dist/src/api/dto/TransferTokenDto.d.ts.map +1 -0
- package/dist/src/auth/SignatureAuth.d.ts.map +1 -0
- package/dist/src/auth/types.d.ts.map +1 -0
- package/dist/src/config/environments.d.ts +45 -0
- package/dist/src/config/environments.d.ts.map +1 -0
- package/dist/{helpers → src/helpers}/sdk.d.ts +23 -13
- package/dist/src/helpers/sdk.d.ts.map +1 -0
- package/dist/src/helpers/wallet.d.ts.map +1 -0
- package/dist/src/index.d.ts +25 -0
- package/dist/src/index.d.ts.map +1 -0
- package/dist/src/services/BundleService.d.ts +197 -0
- package/dist/src/services/BundleService.d.ts.map +1 -0
- package/dist/src/services/DexService.d.ts +84 -0
- package/dist/src/services/DexService.d.ts.map +1 -0
- package/dist/src/services/GalaChainService.d.ts +254 -0
- package/dist/src/services/GalaChainService.d.ts.map +1 -0
- package/dist/src/services/LaunchpadService.d.ts +479 -0
- package/dist/src/services/LaunchpadService.d.ts.map +1 -0
- package/dist/src/services/SignatureService.d.ts.map +1 -0
- package/dist/src/services/TokenClassKeyService.d.ts.map +1 -0
- package/dist/src/services/TokenResolverService.d.ts +154 -0
- package/dist/src/services/TokenResolverService.d.ts.map +1 -0
- package/dist/src/services/WebSocketManager.d.ts.map +1 -0
- package/dist/{api → src}/services/WebSocketService.d.ts +4 -1
- package/dist/src/services/WebSocketService.d.ts.map +1 -0
- package/dist/{types → src/types}/comment.dto.d.ts +14 -5
- package/dist/src/types/comment.dto.d.ts.map +1 -0
- package/dist/{types → src/types}/common.d.ts +36 -1
- package/dist/src/types/common.d.ts.map +1 -0
- package/dist/{types → src/types}/dto.d.ts +19 -0
- package/dist/src/types/dto.d.ts.map +1 -0
- package/dist/{types → src/types}/launchpad.dto.d.ts +216 -30
- package/dist/src/types/launchpad.dto.d.ts.map +1 -0
- package/dist/{types → src/types}/launchpad.validation.d.ts +8 -8
- package/dist/src/types/launchpad.validation.d.ts.map +1 -0
- package/dist/src/types/options.dto.d.ts +281 -0
- package/dist/src/types/options.dto.d.ts.map +1 -0
- package/dist/src/types/result.types.d.ts +120 -0
- package/dist/src/types/result.types.d.ts.map +1 -0
- package/dist/{types → src/types}/trade.dto.d.ts +46 -19
- package/dist/src/types/trade.dto.d.ts.map +1 -0
- package/dist/src/types/transfer.dto.d.ts +161 -0
- package/dist/src/types/transfer.dto.d.ts.map +1 -0
- package/dist/{types → src/types}/user.dto.d.ts +98 -38
- package/dist/src/types/user.dto.d.ts.map +1 -0
- package/dist/src/types/websocket.types.d.ts +82 -0
- package/dist/src/types/websocket.types.d.ts.map +1 -0
- package/dist/src/utils/Logger.d.ts +136 -0
- package/dist/src/utils/Logger.d.ts.map +1 -0
- package/dist/src/utils/SignatureHelper.d.ts +77 -0
- package/dist/src/utils/SignatureHelper.d.ts.map +1 -0
- package/dist/src/utils/adapters.d.ts.map +1 -0
- package/dist/src/utils/agent-config.d.ts.map +1 -0
- package/dist/src/utils/date-utils.d.ts +39 -0
- package/dist/src/utils/date-utils.d.ts.map +1 -0
- package/dist/src/utils/http.d.ts.map +1 -0
- package/dist/src/utils/multipart.d.ts.map +1 -0
- package/dist/src/utils/number-utils.d.ts +57 -0
- package/dist/src/utils/number-utils.d.ts.map +1 -0
- package/dist/src/utils/precision-math.d.ts.map +1 -0
- package/dist/src/utils/slippage-utils.d.ts +70 -0
- package/dist/src/utils/slippage-utils.d.ts.map +1 -0
- package/dist/src/utils/tokenNormalizer.d.ts +111 -0
- package/dist/src/utils/tokenNormalizer.d.ts.map +1 -0
- package/dist/{utils → src/utils}/validation.d.ts +4 -4
- package/dist/src/utils/validation.d.ts.map +1 -0
- package/dist/{utils → src/utils}/wallet.d.ts +2 -2
- package/dist/src/utils/wallet.d.ts.map +1 -0
- package/package.json +10 -12
- package/dist/LaunchpadSDK.d.ts +0 -573
- package/dist/LaunchpadSDK.d.ts.map +0 -1
- package/dist/api/CommentAPI.d.ts +0 -119
- package/dist/api/CommentAPI.d.ts.map +0 -1
- package/dist/api/LaunchpadAPI.d.ts.map +0 -1
- package/dist/api/TradeAPI.d.ts +0 -164
- package/dist/api/TradeAPI.d.ts.map +0 -1
- package/dist/api/Trading.d.ts +0 -176
- package/dist/api/Trading.d.ts.map +0 -1
- package/dist/api/UserAPI.d.ts +0 -426
- package/dist/api/UserAPI.d.ts.map +0 -1
- package/dist/api/WebSocketAPI.d.ts +0 -156
- package/dist/api/WebSocketAPI.d.ts.map +0 -1
- package/dist/api/dto/BondingCurveDTOs.d.ts.map +0 -1
- package/dist/api/services/BundleService.d.ts +0 -105
- package/dist/api/services/BundleService.d.ts.map +0 -1
- package/dist/api/services/SignatureService.d.ts.map +0 -1
- package/dist/api/services/TokenClassKeyService.d.ts.map +0 -1
- package/dist/api/services/WebSocketManager.d.ts.map +0 -1
- package/dist/api/services/WebSocketService.d.ts.map +0 -1
- package/dist/auth/SignatureAuth.d.ts.map +0 -1
- package/dist/auth/types.d.ts.map +0 -1
- package/dist/helpers/sdk.d.ts.map +0 -1
- package/dist/helpers/wallet.d.ts.map +0 -1
- package/dist/index.d.ts +0 -49
- package/dist/index.d.ts.map +0 -1
- package/dist/types/comment.dto.d.ts.map +0 -1
- package/dist/types/common.d.ts.map +0 -1
- package/dist/types/dto.d.ts.map +0 -1
- package/dist/types/launchpad.dto.d.ts.map +0 -1
- package/dist/types/launchpad.validation.d.ts.map +0 -1
- package/dist/types/trade.dto.d.ts.map +0 -1
- package/dist/types/user.dto.d.ts.map +0 -1
- package/dist/utils/VaultCache.d.ts +0 -73
- package/dist/utils/VaultCache.d.ts.map +0 -1
- package/dist/utils/adapters.d.ts.map +0 -1
- package/dist/utils/agent-config.d.ts.map +0 -1
- package/dist/utils/http.d.ts.map +0 -1
- package/dist/utils/multipart.d.ts.map +0 -1
- package/dist/utils/precision-math.d.ts.map +0 -1
- package/dist/utils/validation.d.ts.map +0 -1
- package/dist/utils/wallet.d.ts.map +0 -1
- /package/dist/{auth → src/auth}/SignatureAuth.d.ts +0 -0
- /package/dist/{auth → src/auth}/types.d.ts +0 -0
- /package/dist/{helpers → src/helpers}/wallet.d.ts +0 -0
- /package/dist/{api → src}/services/SignatureService.d.ts +0 -0
- /package/dist/{api → src}/services/TokenClassKeyService.d.ts +0 -0
- /package/dist/{api → src}/services/WebSocketManager.d.ts +0 -0
- /package/dist/{utils → src/utils}/adapters.d.ts +0 -0
- /package/dist/{utils → src/utils}/agent-config.d.ts +0 -0
- /package/dist/{utils → src/utils}/http.d.ts +0 -0
- /package/dist/{utils → src/utils}/multipart.d.ts +0 -0
- /package/dist/{utils → src/utils}/precision-math.d.ts +0 -0
package/README.md
CHANGED
|
@@ -1,21 +1,22 @@
|
|
|
1
|
-
# Gala Launchpad SDK
|
|
1
|
+
# Gala Launchpad SDK v3.0.0
|
|
2
2
|
|
|
3
3
|
A comprehensive TypeScript SDK for the Gala Launchpad Backend API, providing type-safe authentication, trading, and real-time features for DeFi applications.
|
|
4
4
|
|
|
5
|
+
> **✨ New in v3.0.0**: Production-ready release with service-based architecture, AgentConfig utilities, and clean result types - zero breaking changes!
|
|
6
|
+
|
|
5
7
|
[](https://badge.fury.io/js/@gala-chain%2Flaunchpad-sdk)
|
|
6
8
|
[](https://opensource.org/licenses/MIT)
|
|
7
9
|
[](http://www.typescriptlang.org/)
|
|
8
10
|
|
|
9
11
|
## 🚀 Features
|
|
10
12
|
|
|
11
|
-
**
|
|
13
|
+
**Clean Result Types with No Wrapper Overhead:**
|
|
12
14
|
|
|
13
|
-
- **
|
|
14
|
-
- **
|
|
15
|
-
- **
|
|
16
|
-
- **
|
|
17
|
-
- **
|
|
18
|
-
- **Flat API Design**: All methods directly on SDK root for simplicity
|
|
15
|
+
- **Direct Result Access**: Get clean, typed results without wrapper objects
|
|
16
|
+
- **Semantic Type Conversion**: Dates as Date objects, numbers as numbers, strings for precision
|
|
17
|
+
- **Comprehensive Type Safety**: Full TypeScript support with precise result interfaces
|
|
18
|
+
- **Zero Wrapper Overhead**: No more `result.data.success` - direct property access
|
|
19
|
+
- **Options Object Pattern**: All methods with 2+ parameters use clean options objects
|
|
19
20
|
|
|
20
21
|
### Developer Experience
|
|
21
22
|
|
|
@@ -27,35 +28,46 @@ const sdk = createLaunchpadSDK({
|
|
|
27
28
|
wallet: 'your-private-key-or-mnemonic' // Auto-detects format!
|
|
28
29
|
});
|
|
29
30
|
|
|
30
|
-
//
|
|
31
|
-
const
|
|
32
|
-
|
|
31
|
+
// Direct result access - no wrapper objects!
|
|
32
|
+
const pools = await sdk.fetchPools({ type: 'recent' });
|
|
33
|
+
console.log(`Found ${pools.total} pools`); // Direct property access
|
|
34
|
+
console.log(`Page ${pools.page} of ${pools.totalPages}`); // Clean pagination
|
|
35
|
+
console.log(`Has next: ${pools.hasNext}`); // Boolean convenience properties
|
|
33
36
|
|
|
34
|
-
//
|
|
35
|
-
const
|
|
37
|
+
// Clean typed results everywhere
|
|
38
|
+
const balance = await sdk.fetchGalaBalance();
|
|
39
|
+
console.log(`Balance: ${balance.balance} GALA`); // Direct balance access
|
|
40
|
+
console.log(`Last updated: ${balance.lastUpdated.toISOString()}`); // Date object
|
|
36
41
|
```
|
|
37
42
|
|
|
38
|
-
## 📊
|
|
43
|
+
## 📊 Clean API Architecture
|
|
39
44
|
|
|
40
|
-
**
|
|
45
|
+
**Direct result access with no wrapper overhead:**
|
|
41
46
|
|
|
42
47
|
```typescript
|
|
43
|
-
//
|
|
44
|
-
await sdk.fetchPools({ type: 'recent' });
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
48
|
+
// Before: Wrapper response types
|
|
49
|
+
const result = await sdk.fetchPools({ type: 'recent' });
|
|
50
|
+
if (result.success) {
|
|
51
|
+
console.log(result.data.pools); // Nested access
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
// After: Clean direct results
|
|
55
|
+
const pools = await sdk.fetchPools({ type: 'recent' });
|
|
56
|
+
console.log(pools.pools); // Direct access
|
|
57
|
+
console.log(pools.total); // Immediate pagination info
|
|
58
|
+
console.log(pools.hasNext); // Computed convenience properties
|
|
49
59
|
```
|
|
50
60
|
|
|
51
61
|
## 🚀 Key Features
|
|
52
62
|
|
|
53
63
|
- **Type-Safe API Client**: Full TypeScript support with comprehensive type definitions
|
|
64
|
+
- **Clean Result Types**: Direct property access without wrapper objects
|
|
65
|
+
- **Options Object Pattern**: All multi-parameter methods use clean options objects
|
|
54
66
|
- **Signature Authentication**: Ethereum wallet-based authentication with automatic signature generation
|
|
55
67
|
- **Helper Functions**: Auto-detecting wallet creation and SDK factory functions
|
|
56
|
-
- **Flat API Design**: All methods directly accessible on SDK root
|
|
57
68
|
- **Pool Management**: Create, fetch, and check token pools on the launchpad
|
|
58
69
|
- **Token Trading**: Buy and sell tokens with slippage protection via GalaChain
|
|
70
|
+
- **Token Transfers**: Transfer GALA and launchpad tokens between wallets with EIP-712 signatures
|
|
59
71
|
- **User Operations**: Portfolio management, token balances, and account management
|
|
60
72
|
- **Comment System**: Post and retrieve comments on token pools
|
|
61
73
|
- **Comprehensive Validation**: Input validation and error handling for all operations
|
|
@@ -64,13 +76,13 @@ await sdk.postComment({ tokenName: 'token', content: 'Great project!' });
|
|
|
64
76
|
## 📦 Installation
|
|
65
77
|
|
|
66
78
|
```bash
|
|
67
|
-
npm install @gala-chain/launchpad-sdk@^0.
|
|
79
|
+
npm install @gala-chain/launchpad-sdk@^3.0.0
|
|
68
80
|
```
|
|
69
81
|
|
|
70
82
|
Or with yarn:
|
|
71
83
|
|
|
72
84
|
```bash
|
|
73
|
-
yarn add @gala-chain/launchpad-sdk@^0.
|
|
85
|
+
yarn add @gala-chain/launchpad-sdk@^3.0.0
|
|
74
86
|
```
|
|
75
87
|
|
|
76
88
|
## 🏁 Quick Start
|
|
@@ -85,39 +97,66 @@ const sdk = createLaunchpadSDK({
|
|
|
85
97
|
wallet: 'your-private-key-or-mnemonic' // Auto-detects format!
|
|
86
98
|
});
|
|
87
99
|
|
|
88
|
-
//
|
|
100
|
+
// Clean, direct result access - All methods use options objects
|
|
89
101
|
|
|
90
|
-
// Pool Management
|
|
102
|
+
// Pool Management - Direct result properties
|
|
91
103
|
const pools = await sdk.fetchPools({ type: 'recent', limit: 10 });
|
|
104
|
+
console.log(`Found ${pools.total} pools across ${pools.totalPages} pages`);
|
|
105
|
+
console.log(`Current page: ${pools.page}, Has next: ${pools.hasNext}`);
|
|
106
|
+
|
|
92
107
|
const badges = await sdk.fetchTokenBadges('dragnrkti');
|
|
93
|
-
|
|
108
|
+
console.log(`Volume badges: ${badges.volumeBadges.length}`);
|
|
109
|
+
console.log(`Engagement badges: ${badges.engagementBadges.length}`);
|
|
94
110
|
|
|
95
|
-
|
|
111
|
+
const details = await sdk.fetchPoolDetails('dragnrkti');
|
|
112
|
+
console.log(`Sale status: ${details.saleStatus}`);
|
|
113
|
+
console.log(`Native token quantity: ${details.nativeTokenQuantity}`);
|
|
114
|
+
|
|
115
|
+
// Price Calculations - Direct amount access
|
|
96
116
|
const buyAmount = await sdk.calculateBuyAmount({
|
|
97
117
|
tokenName: 'dragnrkti',
|
|
98
118
|
amount: '1000000000000000000', // 1 GALA
|
|
99
119
|
type: 'native'
|
|
100
120
|
});
|
|
121
|
+
console.log(`Buy amount: ${buyAmount.amount}`);
|
|
122
|
+
console.log(`Transaction fee: ${buyAmount.transactionFee}`);
|
|
101
123
|
|
|
102
|
-
// Trading Operations
|
|
124
|
+
// Trading Operations - Required expectedAmount and slippageToleranceFactor
|
|
103
125
|
const buyResult = await sdk.buy({
|
|
104
126
|
tokenName: 'dragnrkti',
|
|
105
127
|
amount: '1000000000000000000',
|
|
106
128
|
type: 'native',
|
|
107
|
-
|
|
129
|
+
expectedAmount: buyAmount.amount, // Required: from calculation
|
|
130
|
+
slippageToleranceFactor: 0.05 // Required: decimal format (5% slippage)
|
|
108
131
|
});
|
|
132
|
+
console.log(`Transaction ID: ${buyResult.transactionId}`);
|
|
109
133
|
|
|
110
|
-
// Data & Analytics
|
|
134
|
+
// Data & Analytics - Clean pagination
|
|
111
135
|
const trades = await sdk.fetchTrades({ tokenName: 'dragnrkti' });
|
|
136
|
+
console.log(`Found ${trades.total} trades`);
|
|
137
|
+
console.log(`Page ${trades.page} of ${trades.totalPages}`);
|
|
138
|
+
trades.trades.forEach(trade => {
|
|
139
|
+
console.log(`Trade: ${trade.tradeType} ${trade.tokenAmount} at ${trade.createdAt.toISOString()}`);
|
|
140
|
+
});
|
|
141
|
+
|
|
112
142
|
const comments = await sdk.fetchComments({ tokenName: 'dragnrkti' });
|
|
113
|
-
|
|
143
|
+
console.log(`${comments.total} comments found`);
|
|
144
|
+
|
|
145
|
+
// User Operations - Direct balance access
|
|
146
|
+
const galaBalance = await sdk.fetchGalaBalance();
|
|
147
|
+
console.log(`GALA Balance: ${galaBalance.balance}`);
|
|
148
|
+
console.log(`Last updated: ${galaBalance.lastUpdated.toISOString()}`);
|
|
114
149
|
|
|
115
|
-
// User Operations
|
|
116
|
-
const profile = await sdk.fetchProfile();
|
|
117
150
|
const tokenBalance = await sdk.fetchTokenBalance({
|
|
118
151
|
tokenName: 'dragnrkti',
|
|
119
152
|
walletAddress: sdk.getAddress()
|
|
120
153
|
});
|
|
154
|
+
console.log(`Token balance: ${tokenBalance.quantity}`);
|
|
155
|
+
console.log(`USD value: $${tokenBalance.holdingPriceUsd}`);
|
|
156
|
+
|
|
157
|
+
// Profile - Direct user data
|
|
158
|
+
const profile = await sdk.fetchProfile();
|
|
159
|
+
console.log(`Profile name: ${profile.fullName || 'Not set'}`);
|
|
121
160
|
```
|
|
122
161
|
|
|
123
162
|
### Manual SDK Creation (Alternative)
|
|
@@ -137,11 +176,12 @@ const sdk = new LaunchpadSDK({
|
|
|
137
176
|
debug: false
|
|
138
177
|
});
|
|
139
178
|
|
|
140
|
-
// Same
|
|
179
|
+
// Same clean API available
|
|
141
180
|
const pools = await sdk.fetchPools({ type: 'recent' });
|
|
181
|
+
console.log(`${pools.total} pools found`);
|
|
142
182
|
```
|
|
143
183
|
|
|
144
|
-
## 🎯 Complete Example: Trading Flow
|
|
184
|
+
## 🎯 Complete Example: Trading Flow with Clean Results
|
|
145
185
|
|
|
146
186
|
```typescript
|
|
147
187
|
import { createLaunchpadSDK } from '@gala-chain/launchpad-sdk';
|
|
@@ -151,86 +191,208 @@ const sdk = createLaunchpadSDK({
|
|
|
151
191
|
wallet: 'your-private-key-or-mnemonic'
|
|
152
192
|
});
|
|
153
193
|
|
|
154
|
-
// 2. Check available pools
|
|
194
|
+
// 2. Check available pools - direct access to results
|
|
155
195
|
const pools = await sdk.fetchPools({
|
|
156
196
|
type: 'recent',
|
|
157
197
|
limit: 10
|
|
158
198
|
});
|
|
159
199
|
|
|
160
|
-
|
|
200
|
+
console.log(`Found ${pools.total} pools across ${pools.totalPages} pages`);
|
|
201
|
+
pools.pools.forEach(pool => {
|
|
202
|
+
console.log(`Pool: ${pool.tokenName} created at ${pool.createdAt}`);
|
|
203
|
+
});
|
|
204
|
+
|
|
205
|
+
// 3. Get price quote - direct amount access
|
|
161
206
|
const quote = await sdk.calculateBuyAmount({
|
|
162
207
|
tokenName: 'tinyevil',
|
|
163
208
|
amount: '100',
|
|
164
209
|
type: 'native'
|
|
165
210
|
});
|
|
166
211
|
|
|
167
|
-
console.log(`Buying 100 GALA worth
|
|
212
|
+
console.log(`Buying 100 GALA worth will get you: ${quote.amount} TINYEVIL`);
|
|
213
|
+
console.log(`Transaction fee: ${quote.transactionFee} GALA`);
|
|
214
|
+
console.log(`Reverse bonding curve fee: ${quote.reverseBondingCurveFee} GALA`);
|
|
168
215
|
|
|
169
|
-
// 4. Execute trade with slippage protection
|
|
216
|
+
// 4. Execute trade with slippage protection - requires expectedAmount
|
|
170
217
|
const buyResult = await sdk.buy({
|
|
171
218
|
tokenName: 'tinyevil',
|
|
172
219
|
amount: '100',
|
|
173
220
|
type: 'native',
|
|
174
|
-
|
|
221
|
+
expectedAmount: quote.amount, // Required: from calculation above
|
|
222
|
+
slippageToleranceFactor: 0.05 // Required: decimal format for 5% slippage
|
|
175
223
|
});
|
|
176
224
|
|
|
177
|
-
|
|
225
|
+
console.log(`Transaction submitted: ${buyResult.transactionId}`);
|
|
226
|
+
|
|
227
|
+
// 5. Check trade history - clean pagination
|
|
178
228
|
const trades = await sdk.fetchTrades({ tokenName: 'tinyevil' });
|
|
229
|
+
console.log(`Found ${trades.total} trades on page ${trades.page}`);
|
|
230
|
+
console.log(`Has more pages: ${trades.hasNext}`);
|
|
231
|
+
|
|
232
|
+
trades.trades.forEach(trade => {
|
|
233
|
+
console.log(`${trade.tradeType}: ${trade.tokenAmount} at ${trade.createdAt.toISOString()}`);
|
|
234
|
+
});
|
|
179
235
|
|
|
180
236
|
// 6. Post a comment about your trade
|
|
181
|
-
await sdk.postComment({
|
|
237
|
+
const comment = await sdk.postComment({
|
|
182
238
|
tokenName: 'tinyevil',
|
|
183
239
|
content: 'Just bought some tokens! Great project!'
|
|
184
240
|
});
|
|
185
241
|
|
|
186
|
-
|
|
187
|
-
|
|
242
|
+
console.log(`Comment posted with ID: ${comment.id}`);
|
|
243
|
+
|
|
244
|
+
// 7. Check your balance - direct balance access
|
|
245
|
+
const galaBalance = await sdk.fetchGalaBalance();
|
|
246
|
+
console.log(`GALA Balance: ${galaBalance.balance}`);
|
|
247
|
+
console.log(`Decimals: ${galaBalance.decimals}`);
|
|
248
|
+
console.log(`Last updated: ${galaBalance.lastUpdated.toISOString()}`);
|
|
249
|
+
|
|
188
250
|
const tokenBalance = await sdk.fetchTokenBalance({
|
|
189
251
|
tokenName: 'tinyevil',
|
|
190
252
|
walletAddress: sdk.getAddress()
|
|
191
253
|
});
|
|
192
254
|
|
|
193
|
-
console.log(`
|
|
194
|
-
console.log(`
|
|
255
|
+
console.log(`TINYEVIL Balance: ${tokenBalance.quantity}`);
|
|
256
|
+
console.log(`USD Value: $${tokenBalance.holdingPriceUsd}`);
|
|
257
|
+
console.log(`GALA Value: ${tokenBalance.holdingPriceGala} GALA`);
|
|
258
|
+
console.log(`Finalized: ${tokenBalance.isFinalized}`);
|
|
259
|
+
```
|
|
260
|
+
|
|
261
|
+
## 💸 Transfer Operations
|
|
262
|
+
|
|
263
|
+
Transfer GALA and launchpad tokens between wallets with EIP-712 signatures:
|
|
264
|
+
|
|
265
|
+
```typescript
|
|
266
|
+
import { createLaunchpadSDK } from '@gala-chain/launchpad-sdk';
|
|
267
|
+
|
|
268
|
+
const sdk = createLaunchpadSDK({
|
|
269
|
+
wallet: 'your-private-key-or-mnemonic'
|
|
270
|
+
});
|
|
271
|
+
|
|
272
|
+
// Transfer GALA tokens - direct result access
|
|
273
|
+
const galaTransfer = await sdk.transferGala({
|
|
274
|
+
recipientAddress: 'eth|1234567890abcdef1234567890abcdef12345678', // or 0x format
|
|
275
|
+
amount: '1000000000000000000', // 1 GALA in wei
|
|
276
|
+
uniqueKey: 'galaconnect-operation-my-transfer-123' // Optional for idempotency
|
|
277
|
+
});
|
|
278
|
+
|
|
279
|
+
console.log(`GALA Transfer ID: ${galaTransfer.transactionId}`);
|
|
280
|
+
console.log(`Status: ${galaTransfer.status}`);
|
|
281
|
+
|
|
282
|
+
// Transfer launchpad tokens - direct result access
|
|
283
|
+
const tokenTransfer = await sdk.transferToken({
|
|
284
|
+
to: '0x9876543210fedcba9876543210fedcba98765432', // or eth| format
|
|
285
|
+
tokenName: 'tinyevil',
|
|
286
|
+
amount: '1000000', // Token amount in smallest unit
|
|
287
|
+
uniqueKey: 'galaconnect-operation-token-transfer-456' // Optional for idempotency
|
|
288
|
+
});
|
|
289
|
+
|
|
290
|
+
console.log(`Token Transfer ID: ${tokenTransfer.transactionId}`);
|
|
291
|
+
console.log(`Status: ${tokenTransfer.status}`);
|
|
195
292
|
```
|
|
196
293
|
|
|
197
|
-
|
|
294
|
+
### Transfer Features
|
|
295
|
+
- **EIP-712 Signatures**: Secure blockchain transactions
|
|
296
|
+
- **Address Format Handling**: Supports both `0x` and `eth|` formats
|
|
297
|
+
- **Idempotency**: Optional unique keys prevent duplicate transfers (must use `galaswap-operation-` or `galaconnect-operation-` prefix)
|
|
298
|
+
- **Comprehensive Validation**: Amount limits, address formats, token names, unique key formats
|
|
299
|
+
- **GalaChain Integration**: Direct transfers via GalaChain gateway
|
|
300
|
+
- **Error Handling**: Detailed error types for different failure scenarios
|
|
301
|
+
|
|
302
|
+
## 🎯 Available Methods & Result Types
|
|
198
303
|
|
|
199
304
|
### **Fetch Operations**
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
305
|
+
|
|
306
|
+
```typescript
|
|
307
|
+
// Pool Management
|
|
308
|
+
fetchPools(options?): Promise<PoolsResult>
|
|
309
|
+
// Returns: { pools, page, limit, total, totalPages, hasNext, hasPrevious }
|
|
310
|
+
|
|
311
|
+
fetchTokenDistribution(tokenName): Promise<TokenDistributionResult>
|
|
312
|
+
// Returns: { holders, totalSupply, totalHolders, lastUpdated }
|
|
313
|
+
|
|
314
|
+
fetchTokenBadges(tokenName): Promise<TokenBadgesResult>
|
|
315
|
+
// Returns: { volumeBadges, engagementBadges }
|
|
316
|
+
|
|
317
|
+
fetchPoolDetails(tokenName): Promise<PoolDetailsData>
|
|
318
|
+
// Returns: { basePrice, maxSupply, saleStatus, nativeTokenQuantity, ... }
|
|
319
|
+
|
|
320
|
+
fetchVolumeData(options): Promise<GraphDataResult>
|
|
321
|
+
// Returns: { dataPoints }
|
|
322
|
+
|
|
323
|
+
// Trade & User Data
|
|
324
|
+
fetchTrades(options): Promise<TradesResult>
|
|
325
|
+
// Returns: { trades, page, limit, total, totalPages, hasNext, hasPrevious }
|
|
326
|
+
|
|
327
|
+
fetchGalaBalance(walletAddress?): Promise<GalaBalanceInfo>
|
|
328
|
+
// Returns: { userAddress, balance, decimals, lastUpdated }
|
|
329
|
+
|
|
330
|
+
fetchTokenBalance(options): Promise<TokenBalanceInfo>
|
|
331
|
+
// Returns: { quantity, holdingPriceUsd, holdingPriceGala, isFinalized, ... }
|
|
332
|
+
|
|
333
|
+
fetchComments(options): Promise<CommentsResult>
|
|
334
|
+
// Returns: { comments, page, limit, total, totalPages, hasNext, hasPrevious }
|
|
335
|
+
|
|
336
|
+
fetchProfile(walletAddress?): Promise<UserProfile>
|
|
337
|
+
// Returns: { fullName, profileImage, walletAddress, ... }
|
|
338
|
+
```
|
|
210
339
|
|
|
211
340
|
### **Calculate Operations**
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
341
|
+
|
|
342
|
+
```typescript
|
|
343
|
+
// Price Calculations
|
|
344
|
+
calculateBuyAmount(options): Promise<AmountCalculationResult>
|
|
345
|
+
// Returns: { amount, reverseBondingCurveFee, transactionFee }
|
|
346
|
+
|
|
347
|
+
calculateSellAmount(options): Promise<AmountCalculationResult>
|
|
348
|
+
// Returns: { amount, reverseBondingCurveFee, transactionFee }
|
|
349
|
+
|
|
350
|
+
calculateInitialBuyAmount(options): Promise<AmountCalculationResult>
|
|
351
|
+
// Returns: { amount, reverseBondingCurveFee, transactionFee }
|
|
352
|
+
```
|
|
215
353
|
|
|
216
354
|
### **Trading Operations**
|
|
217
|
-
|
|
218
|
-
|
|
355
|
+
|
|
356
|
+
```typescript
|
|
357
|
+
// Buy/Sell Tokens
|
|
358
|
+
buy(options): Promise<TransactionResult>
|
|
359
|
+
// Options: { tokenName, amount, type, expectedAmount, slippageToleranceFactor }
|
|
360
|
+
// Returns: { transactionId, status, ... }
|
|
361
|
+
|
|
362
|
+
sell(options): Promise<TransactionResult>
|
|
363
|
+
// Options: { tokenName, amount, type, expectedAmount, slippageToleranceFactor }
|
|
364
|
+
// Returns: { transactionId, status, ... }
|
|
365
|
+
```
|
|
219
366
|
|
|
220
367
|
### **Content Operations**
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
368
|
+
|
|
369
|
+
```typescript
|
|
370
|
+
// Comments & Content
|
|
371
|
+
postComment(options): Promise<CommentResult>
|
|
372
|
+
// Returns: { id, content, createdAt, ... }
|
|
373
|
+
|
|
374
|
+
// Token Creation & Management
|
|
375
|
+
launchToken(data): Promise<LaunchTokenResult>
|
|
376
|
+
// Returns: { transactionId, status, ... }
|
|
377
|
+
|
|
378
|
+
uploadTokenImage(options): Promise<ImageUploadResult>
|
|
379
|
+
// Returns: { imageUrl, success, ... }
|
|
380
|
+
|
|
381
|
+
// Profile Management
|
|
382
|
+
updateProfile(data): Promise<ProfileUpdateResult>
|
|
383
|
+
// Returns: { success, data, ... }
|
|
384
|
+
|
|
385
|
+
uploadProfileImage(options): Promise<ImageUploadResult>
|
|
386
|
+
// Returns: { imageUrl, success, ... }
|
|
387
|
+
```
|
|
226
388
|
|
|
227
389
|
### **Validation & Utilities**
|
|
228
|
-
- `isTokenNameAvailable(tokenName)
|
|
229
|
-
- `isTokenSymbolAvailable(symbol)
|
|
230
|
-
- `getAddress()` - Get backend format address (eth|...)
|
|
231
|
-
- `getEthereumAddress()` - Get Ethereum format address (0x...)
|
|
232
|
-
- `resolveVaultAddress(tokenName)
|
|
233
|
-
- `cleanup()` - Cleanup resources
|
|
390
|
+
- `isTokenNameAvailable(tokenName: string): Promise<boolean>`
|
|
391
|
+
- `isTokenSymbolAvailable(symbol: string): Promise<boolean>`
|
|
392
|
+
- `getAddress(): string` - Get backend format address (eth|...)
|
|
393
|
+
- `getEthereumAddress(): string` - Get Ethereum format address (0x...)
|
|
394
|
+
- `resolveVaultAddress(tokenName: string): Promise<string>`
|
|
395
|
+
- `cleanup(): void` - Cleanup resources
|
|
234
396
|
|
|
235
397
|
## 🔧 Helper Functions
|
|
236
398
|
|
|
@@ -300,10 +462,131 @@ npm run lint
|
|
|
300
462
|
## 📚 Documentation
|
|
301
463
|
|
|
302
464
|
- [SDK Method Reference](./SDK-METHOD-GRAPH.md) - Complete flat API reference
|
|
303
|
-
- [
|
|
465
|
+
- [Clean Result Types Migration Guide](./docs/CLEAN_RESULT_TYPES_MIGRATION.md) - Migration guide for clean result types
|
|
466
|
+
- [Service Architecture Migration Guide](./docs/SERVICE_ARCHITECTURE_MIGRATION.md) - Guide for v3.1.0 service-based architecture
|
|
304
467
|
- [API Documentation](../../API.md) - Detailed API documentation
|
|
305
468
|
- [Examples](./examples/) - Code examples and demos
|
|
306
469
|
|
|
470
|
+
## 🏗️ Architecture (v3.0.0+)
|
|
471
|
+
|
|
472
|
+
The SDK uses a **service-based architecture** with backend-aligned services:
|
|
473
|
+
|
|
474
|
+
### Backend-Aligned Services
|
|
475
|
+
|
|
476
|
+
```typescript
|
|
477
|
+
// Each service maps 1:1 to a specific backend
|
|
478
|
+
import {
|
|
479
|
+
LaunchpadService, // → launchpad-backend (pools, trades, comments, profiles)
|
|
480
|
+
GalaChainService, // → galachain-gateway (balances, transfers, pool details)
|
|
481
|
+
DexService, // → dex-api (spot prices)
|
|
482
|
+
BundleService, // → bundle-backend (transaction bundling, trading)
|
|
483
|
+
WebSocketService // → WebSocket endpoint (real-time monitoring)
|
|
484
|
+
} from '@gala-chain/launchpad-sdk';
|
|
485
|
+
```
|
|
486
|
+
|
|
487
|
+
### Service Responsibilities
|
|
488
|
+
|
|
489
|
+
**LaunchpadService** - Launchpad Backend Operations
|
|
490
|
+
- Pool management (fetch, create, check)
|
|
491
|
+
- Trade history
|
|
492
|
+
- Comments (post, fetch)
|
|
493
|
+
- User profiles
|
|
494
|
+
- Token images
|
|
495
|
+
- Faucet operations
|
|
496
|
+
|
|
497
|
+
**GalaChainService** - Blockchain Operations
|
|
498
|
+
- GALA balance queries
|
|
499
|
+
- Token balance queries
|
|
500
|
+
- Token transfers (GALA & launchpad tokens)
|
|
501
|
+
- Pool details from bonding curve contracts
|
|
502
|
+
- Token resolution
|
|
503
|
+
|
|
504
|
+
**DexService** - Price Queries
|
|
505
|
+
- Spot price fetching
|
|
506
|
+
- Multi-token price queries
|
|
507
|
+
|
|
508
|
+
**BundleService** - Transaction Bundling
|
|
509
|
+
- Buy token operations
|
|
510
|
+
- Sell token operations
|
|
511
|
+
- Slippage protection
|
|
512
|
+
- Transaction bundling
|
|
513
|
+
|
|
514
|
+
**WebSocketService** - Real-time Features
|
|
515
|
+
- Transaction monitoring
|
|
516
|
+
- Status updates
|
|
517
|
+
- Connection management
|
|
518
|
+
|
|
519
|
+
### Benefits of Service Architecture
|
|
520
|
+
|
|
521
|
+
✅ **Clear Separation**: Each service has a single backend responsibility
|
|
522
|
+
✅ **Type Safety**: Full TypeScript support across all services
|
|
523
|
+
✅ **Testability**: Services can be tested independently
|
|
524
|
+
✅ **Maintainability**: Easy to locate and update backend-specific logic
|
|
525
|
+
✅ **Zero Breaking Changes**: Public API remains unchanged (v3.0.0 is fully backward compatible)
|
|
526
|
+
|
|
527
|
+
### 🤖 AI Agent Integration
|
|
528
|
+
|
|
529
|
+
The SDK includes comprehensive utilities for AI agent development:
|
|
530
|
+
|
|
531
|
+
```typescript
|
|
532
|
+
import { AgentConfig } from '@gala-chain/launchpad-sdk';
|
|
533
|
+
|
|
534
|
+
// Quick setup with intelligent defaults
|
|
535
|
+
const { sdk, validation } = await AgentConfig.quickSetup({
|
|
536
|
+
environment: 'development',
|
|
537
|
+
autoValidate: true
|
|
538
|
+
});
|
|
539
|
+
|
|
540
|
+
console.log(`Ready: ${validation.ready}`);
|
|
541
|
+
console.log(`Can trade: ${validation.capabilities.canTrade}`);
|
|
542
|
+
```
|
|
543
|
+
|
|
544
|
+
For comprehensive AI agent integration, see:
|
|
545
|
+
- [AI Agent Integration Guide](./docs/AI-AGENT-GUIDE.md) - Complete guide for agent development
|
|
546
|
+
- [MCP Tool Specification](./docs/MCP-TOOL-SPECIFICATION.md) - Blueprint for MCP server creation
|
|
547
|
+
- [Agent Examples](./docs/agent-examples/) - Working code examples
|
|
548
|
+
|
|
549
|
+
## 🎯 Clean Result Types Architecture
|
|
550
|
+
|
|
551
|
+
### Key Benefits
|
|
552
|
+
|
|
553
|
+
✅ **Direct Property Access**: No more `result.data.success` chains
|
|
554
|
+
✅ **Type Safety**: Full TypeScript IntelliSense for all result properties
|
|
555
|
+
✅ **Semantic Types**: Dates as Date objects, numbers as numbers
|
|
556
|
+
✅ **Computed Properties**: `hasNext`, `hasPrevious` for convenience
|
|
557
|
+
✅ **Zero Wrapper Overhead**: Clean, direct access to all result data
|
|
558
|
+
✅ **Options Object Pattern**: All multi-parameter methods use options objects
|
|
559
|
+
|
|
560
|
+
### Result Type Examples
|
|
561
|
+
|
|
562
|
+
```typescript
|
|
563
|
+
// Pool results with pagination
|
|
564
|
+
interface PoolsResult {
|
|
565
|
+
pools: PoolData[]; // Direct pool array
|
|
566
|
+
page: number; // Current page
|
|
567
|
+
total: number; // Total items
|
|
568
|
+
hasNext: boolean; // Computed convenience
|
|
569
|
+
// ... more properties
|
|
570
|
+
}
|
|
571
|
+
|
|
572
|
+
// Token balance with typed values
|
|
573
|
+
interface TokenBalanceInfo {
|
|
574
|
+
quantity: string; // Token amount (string for precision)
|
|
575
|
+
holdingPriceUsd: number; // USD value (number for math)
|
|
576
|
+
lastUpdated: Date; // Date object (not string)
|
|
577
|
+
isFinalized: boolean; // Boolean flag
|
|
578
|
+
// ... more properties
|
|
579
|
+
}
|
|
580
|
+
|
|
581
|
+
// Trading results
|
|
582
|
+
interface AmountCalculationResult {
|
|
583
|
+
amount: string; // Calculated amount
|
|
584
|
+
transactionFee: string; // Fee breakdown
|
|
585
|
+
reverseBondingCurveFee: string; // RBC fee
|
|
586
|
+
// Direct access to all calculation data
|
|
587
|
+
}
|
|
588
|
+
```
|
|
589
|
+
|
|
307
590
|
## 🚀 Environment URLs
|
|
308
591
|
|
|
309
592
|
- **Development**: `https://lpad-backend-dev1.defi.gala.com`
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
#!/usr/bin/env tsx
|
|
2
|
+
/**
|
|
3
|
+
* 🚀 GALA LAUNCHPAD SDK - COMPLETE DEMONSTRATION
|
|
4
|
+
*
|
|
5
|
+
* This is the ONLY demo you need! It covers every feature of the SDK:
|
|
6
|
+
*
|
|
7
|
+
* ✅ Token Creation & Management
|
|
8
|
+
* ✅ All Trading Operations (buy/sell with native/exact amounts)
|
|
9
|
+
* ✅ User Profile & Social Features
|
|
10
|
+
* ✅ Transfer Operations (GALA & Tokens)
|
|
11
|
+
* ✅ Data Fetching (pools, balances, history)
|
|
12
|
+
* ✅ Automatic Transaction Confirmation (WebSocket internal)
|
|
13
|
+
* ✅ Error Handling & Recovery
|
|
14
|
+
*
|
|
15
|
+
* Run with: npx tsx examples/complete-sdk-demo.ts
|
|
16
|
+
*/
|
|
17
|
+
/**
|
|
18
|
+
* 🎯 Main demo function
|
|
19
|
+
*/
|
|
20
|
+
declare function runCompleteSDKDemo(): Promise<void>;
|
|
21
|
+
export { runCompleteSDKDemo };
|
|
22
|
+
//# sourceMappingURL=complete-sdk-demo.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"complete-sdk-demo.d.ts","sourceRoot":"","sources":["../../examples/complete-sdk-demo.ts"],"names":[],"mappings":";AAEA;;;;;;;;;;;;;;GAcG;AAiNH;;GAEG;AACH,iBAAe,kBAAkB,IAAI,OAAO,CAAC,IAAI,CAAC,CA6+BjD;AAYD,OAAO,EAAE,kBAAkB,EAAE,CAAC"}
|