@gala-chain/launchpad-sdk 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +46 -0
- package/README.md +628 -0
- package/dist/LaunchpadSDK.d.ts +573 -0
- package/dist/LaunchpadSDK.d.ts.map +1 -0
- package/dist/api/CommentAPI.d.ts +119 -0
- package/dist/api/CommentAPI.d.ts.map +1 -0
- package/dist/api/LaunchpadAPI.d.ts +440 -0
- package/dist/api/LaunchpadAPI.d.ts.map +1 -0
- package/dist/api/TradeAPI.d.ts +164 -0
- package/dist/api/TradeAPI.d.ts.map +1 -0
- package/dist/api/Trading.d.ts +176 -0
- package/dist/api/Trading.d.ts.map +1 -0
- package/dist/api/UserAPI.d.ts +426 -0
- package/dist/api/UserAPI.d.ts.map +1 -0
- package/dist/api/WebSocketAPI.d.ts +156 -0
- package/dist/api/WebSocketAPI.d.ts.map +1 -0
- package/dist/api/dto/BondingCurveDTOs.d.ts +142 -0
- package/dist/api/dto/BondingCurveDTOs.d.ts.map +1 -0
- package/dist/api/services/BundleService.d.ts +105 -0
- package/dist/api/services/BundleService.d.ts.map +1 -0
- package/dist/api/services/SignatureService.d.ts +71 -0
- package/dist/api/services/SignatureService.d.ts.map +1 -0
- package/dist/api/services/TokenClassKeyService.d.ts +116 -0
- package/dist/api/services/TokenClassKeyService.d.ts.map +1 -0
- package/dist/api/services/WebSocketManager.d.ts +99 -0
- package/dist/api/services/WebSocketManager.d.ts.map +1 -0
- package/dist/api/services/WebSocketService.d.ts +66 -0
- package/dist/api/services/WebSocketService.d.ts.map +1 -0
- package/dist/auth/SignatureAuth.d.ts +92 -0
- package/dist/auth/SignatureAuth.d.ts.map +1 -0
- package/dist/auth/types.d.ts +41 -0
- package/dist/auth/types.d.ts.map +1 -0
- package/dist/helpers/sdk.d.ts +75 -0
- package/dist/helpers/sdk.d.ts.map +1 -0
- package/dist/helpers/wallet.d.ts +60 -0
- package/dist/helpers/wallet.d.ts.map +1 -0
- package/dist/index.cjs.js +1 -0
- package/dist/index.d.ts +49 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.esm.js +1 -0
- package/dist/index.js +1 -0
- package/dist/types/comment.dto.d.ts +160 -0
- package/dist/types/comment.dto.d.ts.map +1 -0
- package/dist/types/common.d.ts +108 -0
- package/dist/types/common.d.ts.map +1 -0
- package/dist/types/dto.d.ts +145 -0
- package/dist/types/dto.d.ts.map +1 -0
- package/dist/types/launchpad.dto.d.ts +517 -0
- package/dist/types/launchpad.dto.d.ts.map +1 -0
- package/dist/types/launchpad.validation.d.ts +40 -0
- package/dist/types/launchpad.validation.d.ts.map +1 -0
- package/dist/types/trade.dto.d.ts +446 -0
- package/dist/types/trade.dto.d.ts.map +1 -0
- package/dist/types/user.dto.d.ts +330 -0
- package/dist/types/user.dto.d.ts.map +1 -0
- package/dist/utils/VaultCache.d.ts +73 -0
- package/dist/utils/VaultCache.d.ts.map +1 -0
- package/dist/utils/adapters.d.ts +111 -0
- package/dist/utils/adapters.d.ts.map +1 -0
- package/dist/utils/agent-config.d.ts +206 -0
- package/dist/utils/agent-config.d.ts.map +1 -0
- package/dist/utils/http.d.ts +85 -0
- package/dist/utils/http.d.ts.map +1 -0
- package/dist/utils/multipart.d.ts +60 -0
- package/dist/utils/multipart.d.ts.map +1 -0
- package/dist/utils/precision-math.d.ts +37 -0
- package/dist/utils/precision-math.d.ts.map +1 -0
- package/dist/utils/validation.d.ts +131 -0
- package/dist/utils/validation.d.ts.map +1 -0
- package/dist/utils/wallet.d.ts +174 -0
- package/dist/utils/wallet.d.ts.map +1 -0
- package/package.json +151 -0
|
@@ -0,0 +1,330 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* User API Data Transfer Objects and Types
|
|
3
|
+
*
|
|
4
|
+
* This module defines all types and interfaces for user operations including
|
|
5
|
+
* token list fetching, faucet transfers, and GALA balance retrieval.
|
|
6
|
+
*/
|
|
7
|
+
import { PaginationParams, AddressFormat } from './common';
|
|
8
|
+
/**
|
|
9
|
+
* User token type enumeration
|
|
10
|
+
*/
|
|
11
|
+
export type UserTokenType = 'all' | 'DEFI' | 'ASSET';
|
|
12
|
+
/**
|
|
13
|
+
* Options for fetching user token list with filtering
|
|
14
|
+
*/
|
|
15
|
+
export interface GetTokenListOptions extends PaginationParams {
|
|
16
|
+
/** Token type filter */
|
|
17
|
+
type?: UserTokenType;
|
|
18
|
+
/** Optional address filter (eth|[40-hex-chars]) */
|
|
19
|
+
address?: AddressFormat;
|
|
20
|
+
/** Optional search filter */
|
|
21
|
+
search?: string;
|
|
22
|
+
/** Optional token name filter */
|
|
23
|
+
tokenName?: string;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Backend format for get token list options (handles type conversion)
|
|
27
|
+
*/
|
|
28
|
+
export interface BackendGetTokenListOptions {
|
|
29
|
+
/** Token type filter */
|
|
30
|
+
type?: string;
|
|
31
|
+
/** Address filter */
|
|
32
|
+
address?: string;
|
|
33
|
+
/** Search filter */
|
|
34
|
+
search?: string;
|
|
35
|
+
/** Token name filter */
|
|
36
|
+
tokenName?: string;
|
|
37
|
+
/** Page number as string (backend quirk) */
|
|
38
|
+
page: string;
|
|
39
|
+
/** Limit as string (backend quirk) */
|
|
40
|
+
limit: string;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Token information in user's token list
|
|
44
|
+
*/
|
|
45
|
+
export interface UserTokenInfo {
|
|
46
|
+
/** Token ID */
|
|
47
|
+
id: string;
|
|
48
|
+
/** Token name */
|
|
49
|
+
name: string;
|
|
50
|
+
/** Token symbol */
|
|
51
|
+
symbol: string;
|
|
52
|
+
/** Token type */
|
|
53
|
+
type: UserTokenType;
|
|
54
|
+
/** Token address */
|
|
55
|
+
address: AddressFormat;
|
|
56
|
+
/** User's balance */
|
|
57
|
+
balance: string;
|
|
58
|
+
/** Token decimals */
|
|
59
|
+
decimals: number;
|
|
60
|
+
/** Token metadata */
|
|
61
|
+
metadata?: {
|
|
62
|
+
description?: string;
|
|
63
|
+
image?: string;
|
|
64
|
+
[key: string]: any;
|
|
65
|
+
};
|
|
66
|
+
/** Token creation timestamp */
|
|
67
|
+
createdAt: string;
|
|
68
|
+
/** Last update timestamp */
|
|
69
|
+
updatedAt: string;
|
|
70
|
+
/** Additional token data */
|
|
71
|
+
[key: string]: any;
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Response from get token list endpoint
|
|
75
|
+
*/
|
|
76
|
+
export interface GetTokenListResponse {
|
|
77
|
+
/** Array of user tokens */
|
|
78
|
+
data: UserTokenInfo[];
|
|
79
|
+
/** Pagination metadata */
|
|
80
|
+
page: number;
|
|
81
|
+
limit: number;
|
|
82
|
+
total: number;
|
|
83
|
+
totalPages: number;
|
|
84
|
+
hasNextPage: boolean;
|
|
85
|
+
hasPrevPage: boolean;
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Data required for transferring faucets to user
|
|
89
|
+
*/
|
|
90
|
+
export interface TransferFaucetsData {
|
|
91
|
+
/** Wallet address in backend format eth|[40-hex-chars] */
|
|
92
|
+
walletAddress: AddressFormat;
|
|
93
|
+
/** Amount to transfer in smallest unit (wei equivalent) */
|
|
94
|
+
amount: string;
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* Response from transfer faucets endpoint
|
|
98
|
+
*/
|
|
99
|
+
export interface TransferFaucetsResponse {
|
|
100
|
+
/** HTTP status code */
|
|
101
|
+
status: number;
|
|
102
|
+
/** Error flag (false for success) */
|
|
103
|
+
error: boolean;
|
|
104
|
+
/** Success/error message from backend */
|
|
105
|
+
message: string;
|
|
106
|
+
/** Optional transfer details (may be added by backend in future) */
|
|
107
|
+
data?: {
|
|
108
|
+
/** Transaction hash */
|
|
109
|
+
txHash?: string;
|
|
110
|
+
/** Amount transferred */
|
|
111
|
+
amount?: string;
|
|
112
|
+
/** Token address */
|
|
113
|
+
tokenAddress?: string;
|
|
114
|
+
/** Transfer timestamp */
|
|
115
|
+
timestamp?: string;
|
|
116
|
+
[key: string]: any;
|
|
117
|
+
};
|
|
118
|
+
}
|
|
119
|
+
/**
|
|
120
|
+
* Options for fetching GALA balance
|
|
121
|
+
*/
|
|
122
|
+
export interface FetchGalaBalanceOptions {
|
|
123
|
+
/** Wallet address in backend format eth|[40-hex-chars]. If not provided, uses SDK wallet address */
|
|
124
|
+
walletAddress?: AddressFormat;
|
|
125
|
+
/** Whether to refresh the balance from the blockchain */
|
|
126
|
+
refresh?: boolean;
|
|
127
|
+
}
|
|
128
|
+
/**
|
|
129
|
+
* GALA balance information
|
|
130
|
+
*/
|
|
131
|
+
export interface GalaBalanceInfo {
|
|
132
|
+
/** User address */
|
|
133
|
+
userAddress: AddressFormat;
|
|
134
|
+
/** GALA balance */
|
|
135
|
+
balance: string;
|
|
136
|
+
/** Balance in readable format */
|
|
137
|
+
formattedBalance?: string;
|
|
138
|
+
/** Token decimals */
|
|
139
|
+
decimals: number;
|
|
140
|
+
/** Last update timestamp */
|
|
141
|
+
lastUpdated: string;
|
|
142
|
+
/** Additional balance metadata */
|
|
143
|
+
[key: string]: any;
|
|
144
|
+
}
|
|
145
|
+
/**
|
|
146
|
+
* Response from fetch GALA balance endpoint
|
|
147
|
+
*/
|
|
148
|
+
export interface FetchGalaBalanceResponse {
|
|
149
|
+
/** Success status */
|
|
150
|
+
success: boolean;
|
|
151
|
+
/** Balance information */
|
|
152
|
+
data?: GalaBalanceInfo;
|
|
153
|
+
/** Error message if fetch failed */
|
|
154
|
+
message?: string;
|
|
155
|
+
}
|
|
156
|
+
/**
|
|
157
|
+
* Data required for updating user profile
|
|
158
|
+
*/
|
|
159
|
+
export interface UpdateProfileData {
|
|
160
|
+
/** Profile image URL or empty string */
|
|
161
|
+
profileImage: string;
|
|
162
|
+
/** User's full name */
|
|
163
|
+
fullName: string;
|
|
164
|
+
/** Wallet address in backend format eth|[40-hex-chars] */
|
|
165
|
+
walletAddress: AddressFormat;
|
|
166
|
+
}
|
|
167
|
+
/**
|
|
168
|
+
* Response from update profile endpoint
|
|
169
|
+
*/
|
|
170
|
+
export interface UpdateProfileResponse {
|
|
171
|
+
/** Success status */
|
|
172
|
+
success: boolean;
|
|
173
|
+
/** Updated profile data */
|
|
174
|
+
data?: any;
|
|
175
|
+
/** Success/error message */
|
|
176
|
+
message?: string;
|
|
177
|
+
}
|
|
178
|
+
/**
|
|
179
|
+
* Options for uploading profile image
|
|
180
|
+
*/
|
|
181
|
+
export interface UploadProfileImageOptions {
|
|
182
|
+
/** Image file - can be browser File object or Node.js Buffer */
|
|
183
|
+
file: File | Buffer;
|
|
184
|
+
/** Wallet address in backend format eth|[40-hex-chars]. If not provided, uses SDK wallet address */
|
|
185
|
+
walletAddress?: AddressFormat;
|
|
186
|
+
}
|
|
187
|
+
/**
|
|
188
|
+
* Response from profile image upload endpoint
|
|
189
|
+
*/
|
|
190
|
+
export interface UploadProfileImageResponse {
|
|
191
|
+
/** Success status */
|
|
192
|
+
success: boolean;
|
|
193
|
+
/** Upload result data */
|
|
194
|
+
data?: {
|
|
195
|
+
/** Uploaded image URL or identifier */
|
|
196
|
+
imageUrl?: string;
|
|
197
|
+
/** Image metadata */
|
|
198
|
+
[key: string]: any;
|
|
199
|
+
};
|
|
200
|
+
/** Error message if upload failed */
|
|
201
|
+
message?: string;
|
|
202
|
+
}
|
|
203
|
+
/**
|
|
204
|
+
* Detailed token balance information for a specific wallet
|
|
205
|
+
*/
|
|
206
|
+
export interface TokenBalanceInfo {
|
|
207
|
+
/** Token image URL */
|
|
208
|
+
image: string;
|
|
209
|
+
/** Token name (lowercase) */
|
|
210
|
+
name: string;
|
|
211
|
+
/** Token verification status */
|
|
212
|
+
verify: boolean;
|
|
213
|
+
/** Token symbol */
|
|
214
|
+
symbol: string;
|
|
215
|
+
/** Token quantity held by the wallet as decimal string */
|
|
216
|
+
quantity: string;
|
|
217
|
+
/** Holding price in USD */
|
|
218
|
+
holdingPriceUsd: number;
|
|
219
|
+
/** Holding price in GALA */
|
|
220
|
+
holdingPriceGala: number;
|
|
221
|
+
/** Whether the token is finalized */
|
|
222
|
+
isFinalized: boolean;
|
|
223
|
+
/** Vault address in backend format */
|
|
224
|
+
vaultAddress: string;
|
|
225
|
+
}
|
|
226
|
+
/**
|
|
227
|
+
* Response from token balance check endpoint
|
|
228
|
+
*/
|
|
229
|
+
export interface GetTokenBalanceResponse {
|
|
230
|
+
/** HTTP status code */
|
|
231
|
+
status: number;
|
|
232
|
+
/** Error status */
|
|
233
|
+
error: boolean;
|
|
234
|
+
/** Response message */
|
|
235
|
+
message: string;
|
|
236
|
+
/** Token balance data */
|
|
237
|
+
data?: {
|
|
238
|
+
/** Array of token balance information (typically single item) */
|
|
239
|
+
token: TokenBalanceInfo[];
|
|
240
|
+
/** Count of tokens returned */
|
|
241
|
+
count: number;
|
|
242
|
+
};
|
|
243
|
+
}
|
|
244
|
+
/**
|
|
245
|
+
* Constraints for user operations
|
|
246
|
+
*/
|
|
247
|
+
export declare const USER_CONSTRAINTS: {
|
|
248
|
+
/** Pagination constraints */
|
|
249
|
+
readonly PAGINATION: {
|
|
250
|
+
readonly MIN_PAGE: 1;
|
|
251
|
+
readonly MAX_PAGE: 1000;
|
|
252
|
+
readonly MIN_LIMIT: 1;
|
|
253
|
+
readonly MAX_LIMIT: 20;
|
|
254
|
+
};
|
|
255
|
+
/** User address pattern */
|
|
256
|
+
readonly USER_ADDRESS: {
|
|
257
|
+
/** User address pattern: eth|[40-hex-chars] */
|
|
258
|
+
readonly PATTERN: RegExp;
|
|
259
|
+
};
|
|
260
|
+
/** Token name constraints */
|
|
261
|
+
readonly TOKEN_NAME: {
|
|
262
|
+
readonly MIN_LENGTH: 1;
|
|
263
|
+
readonly MAX_LENGTH: 50;
|
|
264
|
+
};
|
|
265
|
+
/** Search query constraints */
|
|
266
|
+
readonly SEARCH: {
|
|
267
|
+
readonly MIN_LENGTH: 1;
|
|
268
|
+
readonly MAX_LENGTH: 100;
|
|
269
|
+
};
|
|
270
|
+
/** Faucet amount constraints */
|
|
271
|
+
readonly FAUCET_AMOUNT: {
|
|
272
|
+
/** Pattern for positive decimal numbers greater than zero */
|
|
273
|
+
readonly POSITIVE_NON_ZERO_DECIMAL: RegExp;
|
|
274
|
+
};
|
|
275
|
+
/** Profile constraints */
|
|
276
|
+
readonly PROFILE: {
|
|
277
|
+
readonly FULL_NAME: {
|
|
278
|
+
readonly MIN_LENGTH: 1;
|
|
279
|
+
readonly MAX_LENGTH: 100;
|
|
280
|
+
/** Pattern for alphabets only (first name and optional last name) */
|
|
281
|
+
readonly ALPHABETS_ONLY_PATTERN: RegExp;
|
|
282
|
+
};
|
|
283
|
+
};
|
|
284
|
+
};
|
|
285
|
+
/**
|
|
286
|
+
* Type guard to check if an object is valid GetTokenListOptions
|
|
287
|
+
*/
|
|
288
|
+
export declare function isGetTokenListOptions(obj: any): obj is GetTokenListOptions;
|
|
289
|
+
/**
|
|
290
|
+
* Type guard to check if an object is valid TransferFaucetsData
|
|
291
|
+
*/
|
|
292
|
+
export declare function isTransferFaucetsData(obj: any): obj is TransferFaucetsData;
|
|
293
|
+
/**
|
|
294
|
+
* Type guard to check if an object is valid FetchGalaBalanceOptions
|
|
295
|
+
*/
|
|
296
|
+
export declare function isFetchGalaBalanceOptions(obj: any): obj is FetchGalaBalanceOptions;
|
|
297
|
+
/**
|
|
298
|
+
* Type guard to check if a string is a valid UserTokenType
|
|
299
|
+
*/
|
|
300
|
+
export declare function isUserTokenType(value: string): value is UserTokenType;
|
|
301
|
+
/**
|
|
302
|
+
* Validates user address format
|
|
303
|
+
*/
|
|
304
|
+
export declare function isValidUserAddress(address: string): boolean;
|
|
305
|
+
/**
|
|
306
|
+
* Validates search query format
|
|
307
|
+
*/
|
|
308
|
+
export declare function isValidSearchQuery(search: string): boolean;
|
|
309
|
+
/**
|
|
310
|
+
* Validates token name format for user operations
|
|
311
|
+
*/
|
|
312
|
+
export declare function isValidUserTokenName(tokenName: string): boolean;
|
|
313
|
+
/**
|
|
314
|
+
* Validates faucet amount format (positive, non-zero decimal)
|
|
315
|
+
*/
|
|
316
|
+
export declare function isValidFaucetAmount(amount: string): boolean;
|
|
317
|
+
/**
|
|
318
|
+
* Type guard to check if an object is valid UpdateProfileData
|
|
319
|
+
*/
|
|
320
|
+
export declare function isUpdateProfileData(obj: any): obj is UpdateProfileData;
|
|
321
|
+
/**
|
|
322
|
+
* Validates full name format
|
|
323
|
+
* Backend requires: alphabets only (first name and optional last name)
|
|
324
|
+
*/
|
|
325
|
+
export declare function isValidFullName(fullName: string): boolean;
|
|
326
|
+
/**
|
|
327
|
+
* Type guard to check if an object is valid UploadProfileImageOptions
|
|
328
|
+
*/
|
|
329
|
+
export declare function isUploadProfileImageOptions(obj: any): obj is UploadProfileImageOptions;
|
|
330
|
+
//# sourceMappingURL=user.dto.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"user.dto.d.ts","sourceRoot":"","sources":["../../src/types/user.dto.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,gBAAgB,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAM3D;;GAEG;AACH,MAAM,MAAM,aAAa,GAAG,KAAK,GAAG,MAAM,GAAG,OAAO,CAAC;AAErD;;GAEG;AACH,MAAM,WAAW,mBAAoB,SAAQ,gBAAgB;IAC3D,wBAAwB;IACxB,IAAI,CAAC,EAAE,aAAa,CAAC;IACrB,mDAAmD;IACnD,OAAO,CAAC,EAAE,aAAa,CAAC;IACxB,6BAA6B;IAC7B,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,iCAAiC;IACjC,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED;;GAEG;AACH,MAAM,WAAW,0BAA0B;IACzC,wBAAwB;IACxB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,qBAAqB;IACrB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,oBAAoB;IACpB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,wBAAwB;IACxB,SAAS,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I,iBAAiB,CAQtE;AAED;;;GAGG;AACH,wBAAgB,eAAe,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAUzD;AAED;;GAEG;AACH,wBAAgB,2BAA2B,CAAC,GAAG,EAAE,GAAG,GAAG,GAAG,IAAI,yBAAyB,CAOtF"}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Vault Address Cache Utility
|
|
3
|
+
*
|
|
4
|
+
* Provides centralized caching for tokenName → vaultAddress resolution.
|
|
5
|
+
* Since vault addresses never change after token creation, we can safely
|
|
6
|
+
* cache them in memory for the lifetime of the SDK instance.
|
|
7
|
+
*
|
|
8
|
+
* This eliminates redundant API calls for vault resolution across all SDK methods.
|
|
9
|
+
*/
|
|
10
|
+
import type { LaunchpadAPI } from '../api/LaunchpadAPI';
|
|
11
|
+
/**
|
|
12
|
+
* Simple in-memory cache for vault address resolution
|
|
13
|
+
*
|
|
14
|
+
* Key benefits:
|
|
15
|
+
* - Eliminates redundant API calls for same tokenName
|
|
16
|
+
* - Vault addresses are immutable, so safe to cache indefinitely
|
|
17
|
+
* - Thread-safe singleton pattern
|
|
18
|
+
* - Process-scoped (resets on SDK restart)
|
|
19
|
+
*/
|
|
20
|
+
export declare class VaultCache {
|
|
21
|
+
private static cache;
|
|
22
|
+
/**
|
|
23
|
+
* Gets cached vault address for a token name
|
|
24
|
+
*
|
|
25
|
+
* @param tokenName Token name to lookup
|
|
26
|
+
* @returns Cached vault address or null if not found
|
|
27
|
+
*/
|
|
28
|
+
static get(tokenName: string): string | null;
|
|
29
|
+
/**
|
|
30
|
+
* Caches vault address for a token name
|
|
31
|
+
*
|
|
32
|
+
* @param tokenName Token name (will be normalized to lowercase)
|
|
33
|
+
* @param vaultAddress Vault address to cache
|
|
34
|
+
*/
|
|
35
|
+
static set(tokenName: string, vaultAddress: string): void;
|
|
36
|
+
/**
|
|
37
|
+
* Clears the entire cache
|
|
38
|
+
* Useful for testing or memory cleanup
|
|
39
|
+
*/
|
|
40
|
+
static clear(): void;
|
|
41
|
+
/**
|
|
42
|
+
* Gets cache statistics
|
|
43
|
+
*
|
|
44
|
+
* @returns Object with cache size and keys
|
|
45
|
+
*/
|
|
46
|
+
static getStats(): {
|
|
47
|
+
size: number;
|
|
48
|
+
keys: string[];
|
|
49
|
+
};
|
|
50
|
+
/**
|
|
51
|
+
* Resolves token name to vault address with intelligent caching
|
|
52
|
+
*
|
|
53
|
+
* This is the main method used by all APIs for vault resolution.
|
|
54
|
+
* It checks the cache first, and only makes an API call if needed.
|
|
55
|
+
*
|
|
56
|
+
* @param tokenName Token name to resolve (e.g., 'dragnrkti', 'rocketri')
|
|
57
|
+
* @param launchpadAPI LaunchpadAPI instance for making the resolution call
|
|
58
|
+
* @returns Promise<string | null> Vault address if found, null otherwise
|
|
59
|
+
* @throws ValidationError if LaunchpadAPI is not available
|
|
60
|
+
*/
|
|
61
|
+
static resolveWithCache(tokenName: string, launchpadAPI?: LaunchpadAPI): Promise<string | null>;
|
|
62
|
+
/**
|
|
63
|
+
* Pre-warms the cache with known tokenName → vaultAddress mappings
|
|
64
|
+
* Useful for batch operations or initialization
|
|
65
|
+
*
|
|
66
|
+
* @param mappings Array of {tokenName, vaultAddress} objects
|
|
67
|
+
*/
|
|
68
|
+
static preWarm(mappings: Array<{
|
|
69
|
+
tokenName: string;
|
|
70
|
+
vaultAddress: string;
|
|
71
|
+
}>): void;
|
|
72
|
+
}
|
|
73
|
+
//# sourceMappingURL=VaultCache.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"VaultCache.d.ts","sourceRoot":"","sources":["../../src/utils/VaultCache.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAGH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAExD;;;;;;;;GAQG;AACH,qBAAa,UAAU;IACrB,OAAO,CAAC,MAAM,CAAC,KAAK,CAA6B;IAEjD;;;;;OAKG;IACH,MAAM,CAAC,GAAG,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI;IAI5C;;;;;OAKG;IACH,MAAM,CAAC,GAAG,CAAC,SAAS,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,GAAG,IAAI;IAIzD;;;OAGG;IACH,MAAM,CAAC,KAAK,IAAI,IAAI;IAIpB;;;;OAIG;IACH,MAAM,CAAC,QAAQ,IAAI;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,EAAE,CAAA;KAAE;IAOnD;;;;;;;;;;OAUG;WACU,gBAAgB,CAC3B,SAAS,EAAE,MAAM,EACjB,YAAY,CAAC,EAAE,YAAY,GAC1B,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC;IA4DzB;;;;;OAKG;IACH,MAAM,CAAC,OAAO,CAAC,QAAQ,EAAE,KAAK,CAAC;QAAE,SAAS,EAAE,MAAM,CAAC;QAAC,YAAY,EAAE,MAAM,CAAA;KAAE,CAAC,GAAG,IAAI;CAKnF"}
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
import { PaginationParams } from '../types/common';
|
|
2
|
+
/**
|
|
3
|
+
* Type adapters to handle backend quirks and inconsistencies
|
|
4
|
+
*
|
|
5
|
+
* The backend has some type inconsistencies (strings vs numbers) that we need
|
|
6
|
+
* to handle transparently while providing clean interfaces to SDK users.
|
|
7
|
+
*/
|
|
8
|
+
/**
|
|
9
|
+
* Converts clean pagination parameters to backend's expected string format
|
|
10
|
+
*
|
|
11
|
+
* Backend expects page and limit as strings, but SDK users should use numbers
|
|
12
|
+
*
|
|
13
|
+
* @param pagination Clean pagination parameters
|
|
14
|
+
* @returns Backend-compatible query parameters
|
|
15
|
+
*/
|
|
16
|
+
export declare function adaptPagination(pagination: PaginationParams): Record<string, string>;
|
|
17
|
+
/**
|
|
18
|
+
* Converts clean query parameters to backend's expected format
|
|
19
|
+
*
|
|
20
|
+
* Handles various type conversions the backend expects:
|
|
21
|
+
* - Numbers to strings
|
|
22
|
+
* - Booleans to strings
|
|
23
|
+
* - Arrays to comma-separated strings
|
|
24
|
+
* - Removes undefined/null values
|
|
25
|
+
*
|
|
26
|
+
* @param params Clean query parameters
|
|
27
|
+
* @returns Backend-compatible query parameters
|
|
28
|
+
*/
|
|
29
|
+
export declare function adaptQueryParams(params: Record<string, any>): Record<string, string>;
|
|
30
|
+
/**
|
|
31
|
+
* Adapts request data for backend consumption
|
|
32
|
+
*
|
|
33
|
+
* Handles common transformations:
|
|
34
|
+
* - Converts camelCase to snake_case for all fields
|
|
35
|
+
* - Ensures address formats are correct
|
|
36
|
+
* - Handles date/timestamp conversions
|
|
37
|
+
* - Recursively processes nested objects and arrays
|
|
38
|
+
*
|
|
39
|
+
* @param data Request data
|
|
40
|
+
* @param visited Set to track circular references
|
|
41
|
+
* @returns Backend-compatible request data
|
|
42
|
+
*/
|
|
43
|
+
export declare function adaptRequestData(data: Record<string, any>, visited?: WeakSet<object>): Record<string, any>;
|
|
44
|
+
/**
|
|
45
|
+
* Adapts backend response data to clean SDK format
|
|
46
|
+
*
|
|
47
|
+
* Handles common transformations:
|
|
48
|
+
* - Converts snake_case to camelCase for all fields
|
|
49
|
+
* - Parses string numbers back to numbers where appropriate
|
|
50
|
+
* - Standardizes date formats
|
|
51
|
+
* - Recursively processes nested objects and arrays
|
|
52
|
+
*
|
|
53
|
+
* @param data Backend response data
|
|
54
|
+
* @param visited Set to track circular references
|
|
55
|
+
* @returns Clean SDK-compatible data
|
|
56
|
+
*/
|
|
57
|
+
export declare function adaptResponseData<T = any>(data: any, visited?: WeakSet<object>): T;
|
|
58
|
+
/**
|
|
59
|
+
* Known backend type quirks and their handling
|
|
60
|
+
*
|
|
61
|
+
* This documents the specific inconsistencies we've discovered:
|
|
62
|
+
*/
|
|
63
|
+
export declare const BACKEND_TYPE_QUIRKS: {
|
|
64
|
+
/**
|
|
65
|
+
* Pagination parameters must be sent as strings
|
|
66
|
+
* Clean interface: { page: number, limit: number }
|
|
67
|
+
* Backend expects: { page: string, limit: string }
|
|
68
|
+
*/
|
|
69
|
+
readonly PAGINATION_AS_STRINGS: true;
|
|
70
|
+
/**
|
|
71
|
+
* Some numeric fields are returned as strings
|
|
72
|
+
* We convert them back to numbers for clean interfaces
|
|
73
|
+
*/
|
|
74
|
+
readonly NUMERIC_FIELDS_AS_STRINGS: "numeric-strings";
|
|
75
|
+
/**
|
|
76
|
+
* Date fields use inconsistent naming
|
|
77
|
+
* created_at vs createdAt, updated_at vs updatedAt
|
|
78
|
+
*/
|
|
79
|
+
readonly INCONSISTENT_DATE_NAMING: "date-naming";
|
|
80
|
+
/**
|
|
81
|
+
* Array filters may need to be comma-separated strings
|
|
82
|
+
* Clean interface: string[]
|
|
83
|
+
* Backend expects: string (comma-separated)
|
|
84
|
+
*/
|
|
85
|
+
readonly ARRAYS_AS_CSV: "arrays-csv";
|
|
86
|
+
/**
|
|
87
|
+
* Backend expects snake_case field names
|
|
88
|
+
* SDK uses camelCase for clean interfaces
|
|
89
|
+
*/
|
|
90
|
+
readonly SNAKE_CASE_FIELDS: true;
|
|
91
|
+
/**
|
|
92
|
+
* Type parameter handling varies by endpoint
|
|
93
|
+
*/
|
|
94
|
+
readonly TYPE_PARAMETER_HANDLING: {
|
|
95
|
+
readonly TOKEN_LIST_ENDPOINT: {
|
|
96
|
+
readonly includesType: true;
|
|
97
|
+
};
|
|
98
|
+
readonly TOKEN_HELD_ENDPOINT: {
|
|
99
|
+
readonly includesType: false;
|
|
100
|
+
};
|
|
101
|
+
};
|
|
102
|
+
};
|
|
103
|
+
/**
|
|
104
|
+
* Validates that an adapted value matches expected format
|
|
105
|
+
*
|
|
106
|
+
* @param adapted The adapted value
|
|
107
|
+
* @param formatType The expected format ('request' for snake_case, 'response' for camelCase)
|
|
108
|
+
* @throws Error if format is mixed or incorrect
|
|
109
|
+
*/
|
|
110
|
+
export declare function validateAdaptedFormat(adapted: any, formatType: 'request' | 'response'): void;
|
|
111
|
+
//# sourceMappingURL=adapters.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"adapters.d.ts","sourceRoot":"","sources":["../../src/utils/adapters.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AAEnD;;;;;GAKG;AAEH;;;;;;;GAOG;AACH,wBAAgB,eAAe,CAAC,UAAU,EAAE,gBAAgB,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAKpF;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CA6BpF;AAWD;;;;;;;;;;;;GAYG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAAE,OAAO,kBAAgB,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAiDxG;AAWD;;;;;;;;;;;;GAYG;AACH,wBAAgB,iBAAiB,CAAC,CAAC,GAAG,GAAG,EAAE,IAAI,EAAE,GAAG,EAAE,OAAO,kBAAgB,GAAG,CAAC,CAoDhF;AAED;;;;GAIG;AACH,eAAO,MAAM,mBAAmB;IAC9B;;;;OAIG;;IAGH;;;OAGG;;IAGH;;;OAGG;;IAGH;;;;OAIG;;IAGH;;;OAGG;;IAGH;;OAEG;;;;;;;;;CASK,CAAC;AAEX;;;;;;GAMG;AACH,wBAAgB,qBAAqB,CAAC,OAAO,EAAE,GAAG,EAAE,UAAU,EAAE,SAAS,GAAG,UAAU,GAAG,IAAI,CAoB5F"}
|