@gala-chain/launchpad-sdk 4.0.17-beta.0 → 4.0.17-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 +1 -1
- package/dist/index.cjs.js +1 -1
- package/dist/index.d.ts +4 -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 +358 -5
- package/dist/src/LaunchpadSDK.d.ts.map +1 -1
- package/dist/src/bridge/BridgeService.d.ts +47 -1
- package/dist/src/bridge/BridgeService.d.ts.map +1 -1
- package/dist/src/bridge/constants/tokens.d.ts +31 -1
- package/dist/src/bridge/constants/tokens.d.ts.map +1 -1
- package/dist/src/bridge/index.d.ts +1 -1
- package/dist/src/bridge/index.d.ts.map +1 -1
- package/dist/src/bridge/strategies/EthereumBridgeStrategy.d.ts +27 -1
- package/dist/src/bridge/strategies/EthereumBridgeStrategy.d.ts.map +1 -1
- package/dist/src/bridge/types/bridge.dto.d.ts +51 -0
- package/dist/src/bridge/types/bridge.dto.d.ts.map +1 -1
- package/dist/src/bridge/types/bridgeable-token.dto.d.ts +2 -0
- package/dist/src/bridge/types/bridgeable-token.dto.d.ts.map +1 -1
- 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 +4 -1
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/services/BridgeableTokenService.d.ts.map +1 -1
- package/dist/src/services/WrapService.d.ts +153 -0
- package/dist/src/services/WrapService.d.ts.map +1 -0
- package/dist/src/services/WrappableTokenCache.d.ts +128 -0
- package/dist/src/services/WrappableTokenCache.d.ts.map +1 -0
- package/dist/src/services/WrappableTokenService.d.ts +136 -0
- package/dist/src/services/WrappableTokenService.d.ts.map +1 -0
- package/dist/src/types/wrappable-token.dto.d.ts +301 -0
- package/dist/src/types/wrappable-token.dto.d.ts.map +1 -0
- package/package.json +6 -1
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Wrappable Token Service
|
|
3
|
+
*
|
|
4
|
+
* Service for fetching and caching wrappable tokens from the DEX API.
|
|
5
|
+
* Provides methods to query which tokens can be wrapped/unwrapped
|
|
6
|
+
* and retrieves their counterpart tokens dynamically.
|
|
7
|
+
*
|
|
8
|
+
* ## Key Features
|
|
9
|
+
* - Dynamic token discovery (fetches from DEX API)
|
|
10
|
+
* - Permanent caching for token metadata
|
|
11
|
+
* - Separate balance methods for user-specific queries
|
|
12
|
+
*
|
|
13
|
+
* ## Caching Strategy
|
|
14
|
+
* - Token metadata is always cached (fetchWrappableTokens, fetchAllWrappableTokens)
|
|
15
|
+
* - Balance methods never cache (fetchWrappableTokenBalances, fetchAllWrappableTokenBalances)
|
|
16
|
+
* - Cache persists for entire SDK lifetime
|
|
17
|
+
*
|
|
18
|
+
* @category Services
|
|
19
|
+
* @since 4.0.18
|
|
20
|
+
*/
|
|
21
|
+
import { HttpClient } from '../utils/http.js';
|
|
22
|
+
import type { TokenId } from '../types/common.js';
|
|
23
|
+
import type { WrappableToken, FetchWrappableTokensOptions, FetchWrappableTokensResult, IsTokenWrappableResult, WrappableTokenCacheStats } from '../types/wrappable-token.dto.js';
|
|
24
|
+
/**
|
|
25
|
+
* WrappableTokenService
|
|
26
|
+
*
|
|
27
|
+
* Fetches and caches wrappable token information from the DEX API.
|
|
28
|
+
* Provides efficient lookups for wrap/unwrap operations.
|
|
29
|
+
*
|
|
30
|
+
* @example Basic usage
|
|
31
|
+
* ```typescript
|
|
32
|
+
* const service = new WrappableTokenService(dexApiHttp, true);
|
|
33
|
+
*
|
|
34
|
+
* // Fetch all wrappable tokens (cached)
|
|
35
|
+
* const result = await service.fetchAllWrappableTokens();
|
|
36
|
+
* console.log(`Found ${result.tokenCount} tokens`);
|
|
37
|
+
*
|
|
38
|
+
* // Fetch with balance data for a specific address (not cached)
|
|
39
|
+
* const withBalances = await service.fetchAllWrappableTokenBalances('eth|0x1234...');
|
|
40
|
+
* console.log(`Found ${withBalances.tokenCount} tokens with balances`);
|
|
41
|
+
*
|
|
42
|
+
* // Check if a specific token is wrappable (by tokenId)
|
|
43
|
+
* const isWrappable = await service.isTokenWrappable('$MUSIC|Unit|none|none');
|
|
44
|
+
* console.log(`MUSIC wrappable: ${isWrappable.isWrappable}`);
|
|
45
|
+
*
|
|
46
|
+
* // Get wrap counterpart
|
|
47
|
+
* const counterpart = await service.getWrapCounterpart('$MUSIC|Unit|none|none');
|
|
48
|
+
* console.log(`MUSIC counterpart: ${counterpart?.symbol}`); // GMUSIC
|
|
49
|
+
* ```
|
|
50
|
+
*/
|
|
51
|
+
export declare class WrappableTokenService {
|
|
52
|
+
private readonly dexApiHttp;
|
|
53
|
+
private readonly logger;
|
|
54
|
+
private readonly cache;
|
|
55
|
+
constructor(dexApiHttp: HttpClient, debugMode?: boolean);
|
|
56
|
+
/**
|
|
57
|
+
* Normalize tokenId to stringified format for lookups.
|
|
58
|
+
*
|
|
59
|
+
* Accepts:
|
|
60
|
+
* - Pipe-delimited string: "$MUSIC|Unit|none|none"
|
|
61
|
+
* - TokenClassKey object: { collection: '$MUSIC', category: 'Unit', type: 'none', additionalKey: 'none' }
|
|
62
|
+
*
|
|
63
|
+
* @param tokenId - Token identifier
|
|
64
|
+
* @returns Normalized stringified TokenClassKey
|
|
65
|
+
* @throws ValidationError if tokenId format is invalid
|
|
66
|
+
*/
|
|
67
|
+
private normalizeTokenId;
|
|
68
|
+
/**
|
|
69
|
+
* Fetch wrappable tokens with pagination (metadata only, cached)
|
|
70
|
+
*
|
|
71
|
+
* For user-specific balance data, use fetchWrappableTokenBalances() instead.
|
|
72
|
+
*
|
|
73
|
+
* @param options - Fetch options including offset and limit
|
|
74
|
+
* @returns Promise resolving to fetch result with tokens array
|
|
75
|
+
* @throws NetworkError if API request fails
|
|
76
|
+
*/
|
|
77
|
+
fetchWrappableTokens(options?: FetchWrappableTokensOptions): Promise<FetchWrappableTokensResult>;
|
|
78
|
+
/**
|
|
79
|
+
* Fetch ALL wrappable tokens (auto-pagination, cached)
|
|
80
|
+
*
|
|
81
|
+
* Returns cached data if available, otherwise fetches from API.
|
|
82
|
+
* For user-specific balance data, use fetchAllWrappableTokenBalances() instead.
|
|
83
|
+
*
|
|
84
|
+
* @returns Promise resolving to fetch result with all tokens
|
|
85
|
+
* @throws NetworkError if API request fails
|
|
86
|
+
*/
|
|
87
|
+
fetchAllWrappableTokens(): Promise<FetchWrappableTokensResult>;
|
|
88
|
+
/**
|
|
89
|
+
* Get a wrappable token by tokenId
|
|
90
|
+
*
|
|
91
|
+
* Uses cache for efficient lookup. If cache not populated, fetches first.
|
|
92
|
+
*
|
|
93
|
+
* @param tokenId - Token identifier (pipe-delimited or TokenClassKey)
|
|
94
|
+
* @returns Promise resolving to wrappable token or undefined
|
|
95
|
+
*/
|
|
96
|
+
getWrappableToken(tokenId: TokenId): Promise<WrappableToken | undefined>;
|
|
97
|
+
/**
|
|
98
|
+
* Get the wrap counterpart for a token
|
|
99
|
+
*
|
|
100
|
+
* @param tokenId - Token identifier (pipe-delimited or TokenClassKey)
|
|
101
|
+
* @returns Promise resolving to counterpart token or undefined
|
|
102
|
+
*
|
|
103
|
+
* @example
|
|
104
|
+
* ```typescript
|
|
105
|
+
* // Get GMUSIC from MUSIC
|
|
106
|
+
* const counterpart = await service.getWrapCounterpart('$MUSIC|Unit|none|none');
|
|
107
|
+
* console.log(counterpart?.symbol); // "GMUSIC"
|
|
108
|
+
* ```
|
|
109
|
+
*/
|
|
110
|
+
getWrapCounterpart(tokenId: TokenId): Promise<WrappableToken | undefined>;
|
|
111
|
+
/**
|
|
112
|
+
* Check if a token is wrappable
|
|
113
|
+
*
|
|
114
|
+
* @param tokenId - Token identifier (pipe-delimited or TokenClassKey)
|
|
115
|
+
* @returns Promise resolving to wrappability result
|
|
116
|
+
*/
|
|
117
|
+
isTokenWrappable(tokenId: TokenId): Promise<IsTokenWrappableResult>;
|
|
118
|
+
/**
|
|
119
|
+
* Get cache statistics
|
|
120
|
+
*
|
|
121
|
+
* @returns Cache statistics including token count and timestamp
|
|
122
|
+
*/
|
|
123
|
+
getCacheStats(): WrappableTokenCacheStats;
|
|
124
|
+
/**
|
|
125
|
+
* Clear cache
|
|
126
|
+
*/
|
|
127
|
+
clearCache(): void;
|
|
128
|
+
/**
|
|
129
|
+
* Transform API response tokens to SDK format
|
|
130
|
+
*
|
|
131
|
+
* @param apiTokens - Raw API response tokens
|
|
132
|
+
* @returns Array of transformed wrappable tokens
|
|
133
|
+
*/
|
|
134
|
+
private transformTokens;
|
|
135
|
+
}
|
|
136
|
+
//# sourceMappingURL=WrappableTokenService.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"WrappableTokenService.d.ts","sourceRoot":"","sources":["../../../src/services/WrappableTokenService.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAM9C,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,KAAK,EACV,cAAc,EAGd,2BAA2B,EAC3B,0BAA0B,EAC1B,sBAAsB,EACtB,wBAAwB,EACzB,MAAM,iCAAiC,CAAC;AAQzC;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,qBAAa,qBAAqB;IAK9B,OAAO,CAAC,QAAQ,CAAC,UAAU;IAJ7B,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAS;IAChC,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAsB;gBAGzB,UAAU,EAAE,UAAU,EACvC,SAAS,GAAE,OAAe;IAS5B;;;;;;;;;;OAUG;IACH,OAAO,CAAC,gBAAgB;IA0CxB;;;;;;;;OAQG;IACG,oBAAoB,CACxB,OAAO,GAAE,2BAAgC,GACxC,OAAO,CAAC,0BAA0B,CAAC;IA4DtC;;;;;;;;OAQG;IACG,uBAAuB,IAAI,OAAO,CAAC,0BAA0B,CAAC;IA2EpE;;;;;;;OAOG;IACG,iBAAiB,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC,cAAc,GAAG,SAAS,CAAC;IAgB9E;;;;;;;;;;;;OAYG;IACG,kBAAkB,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC,cAAc,GAAG,SAAS,CAAC;IAO/E;;;;;OAKG;IACG,gBAAgB,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC,sBAAsB,CAAC;IAuBzE;;;;OAIG;IACH,aAAa,IAAI,wBAAwB;IAIzC;;OAEG;IACH,UAAU,IAAI,IAAI;IAIlB;;;;;OAKG;IACH,OAAO,CAAC,eAAe;CAwCxB"}
|
|
@@ -0,0 +1,301 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Wrappable Token Types
|
|
3
|
+
*
|
|
4
|
+
* Type definitions for dynamically fetched wrappable tokens from DEX API.
|
|
5
|
+
* Wrappable tokens are token pairs where one can be wrapped/unwrapped into
|
|
6
|
+
* the other (e.g., MUSIC ↔ GMUSIC).
|
|
7
|
+
*
|
|
8
|
+
* @category Types
|
|
9
|
+
* @since 4.0.18
|
|
10
|
+
*/
|
|
11
|
+
import type { TokenId } from './common.js';
|
|
12
|
+
/**
|
|
13
|
+
* Current USD price information from API response
|
|
14
|
+
*/
|
|
15
|
+
export interface WrappableTokenPrices {
|
|
16
|
+
/** Current USD price */
|
|
17
|
+
usd?: number;
|
|
18
|
+
/** 24-hour price change percentage */
|
|
19
|
+
usd24hChange?: number;
|
|
20
|
+
/** 24-hour trading volume in USD */
|
|
21
|
+
usd24hVol?: number;
|
|
22
|
+
/** Market cap in USD */
|
|
23
|
+
usdMarketCap?: number;
|
|
24
|
+
/** Timestamp of last price update */
|
|
25
|
+
lastUpdatedAt?: string;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Raw wrappable token response from DEX API /v1/tokens?wrappable=true
|
|
29
|
+
*
|
|
30
|
+
* This is the structure returned directly from the API.
|
|
31
|
+
*/
|
|
32
|
+
export interface WrappableTokenApiResponse {
|
|
33
|
+
/** Token symbol on GalaChain (e.g., "MUSIC", "GMUSIC") */
|
|
34
|
+
symbol: string;
|
|
35
|
+
/** Token display name */
|
|
36
|
+
name: string;
|
|
37
|
+
/** Token decimals */
|
|
38
|
+
decimals: number;
|
|
39
|
+
/** Token description */
|
|
40
|
+
description?: string;
|
|
41
|
+
/** Token image URL */
|
|
42
|
+
image?: string;
|
|
43
|
+
/** Pipe-delimited token class key (e.g., "$MUSIC|Unit|none|none") */
|
|
44
|
+
stringifiedTokenClassKey: string;
|
|
45
|
+
/** Token collection */
|
|
46
|
+
collection: string;
|
|
47
|
+
/** Token category */
|
|
48
|
+
category: string;
|
|
49
|
+
/** Token type */
|
|
50
|
+
type: string;
|
|
51
|
+
/** Additional key */
|
|
52
|
+
additionalKey: string;
|
|
53
|
+
/** Network (always "GC" for GalaChain) */
|
|
54
|
+
network: string;
|
|
55
|
+
/** Whether the token is verified */
|
|
56
|
+
verified: boolean;
|
|
57
|
+
/** Whether the token is swappable on DEX */
|
|
58
|
+
swappable: boolean;
|
|
59
|
+
/** Token channel (e.g., "music", "asset") */
|
|
60
|
+
channel?: string;
|
|
61
|
+
/** Whether the token is trending */
|
|
62
|
+
trending?: boolean;
|
|
63
|
+
/** Bridge destination chain ID (if bridgeable) */
|
|
64
|
+
bridgeDestinationChainId?: number;
|
|
65
|
+
/** Whether bridging is disabled */
|
|
66
|
+
disableBridge?: boolean;
|
|
67
|
+
/** Price symbol for external price sources */
|
|
68
|
+
priceSymbol?: string;
|
|
69
|
+
/** Whether price is known to external sources */
|
|
70
|
+
priceIsKnownToExternalPriceSource?: boolean;
|
|
71
|
+
/** Counterpart token's stringified TokenClassKey (e.g., "$GMUSIC|Unit|none|none") */
|
|
72
|
+
wrap: string;
|
|
73
|
+
/** Current USD prices (optional) */
|
|
74
|
+
currentPrices?: WrappableTokenPrices;
|
|
75
|
+
/** User's balance (only when address param provided) */
|
|
76
|
+
balance?: string;
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Paginated response from /v1/tokens?wrappable=true API
|
|
80
|
+
*/
|
|
81
|
+
export interface WrappableTokensApiResponse {
|
|
82
|
+
/** Array of wrappable tokens */
|
|
83
|
+
tokens: WrappableTokenApiResponse[];
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Processed wrappable token for SDK use
|
|
87
|
+
*
|
|
88
|
+
* This is the normalized structure used internally by the SDK.
|
|
89
|
+
*/
|
|
90
|
+
export interface WrappableToken {
|
|
91
|
+
/** Token symbol on GalaChain (e.g., "MUSIC", "GMUSIC") */
|
|
92
|
+
symbol: string;
|
|
93
|
+
/** Token display name */
|
|
94
|
+
name: string;
|
|
95
|
+
/** Token decimals */
|
|
96
|
+
decimals: number;
|
|
97
|
+
/** GalaChain token descriptor */
|
|
98
|
+
galaChainDescriptor: {
|
|
99
|
+
collection: string;
|
|
100
|
+
category: string;
|
|
101
|
+
type: string;
|
|
102
|
+
additionalKey: string;
|
|
103
|
+
};
|
|
104
|
+
/** Pipe-delimited token class key */
|
|
105
|
+
stringifiedTokenClassKey: string;
|
|
106
|
+
/** Counterpart token's stringified TokenClassKey */
|
|
107
|
+
wrapCounterpart: string;
|
|
108
|
+
/** Whether the token is swappable on DEX */
|
|
109
|
+
swappable: boolean;
|
|
110
|
+
/** Whether the token is verified */
|
|
111
|
+
verified: boolean;
|
|
112
|
+
/** Token channel (e.g., "music", "asset") */
|
|
113
|
+
channel?: string;
|
|
114
|
+
/** Whether the token is trending */
|
|
115
|
+
trending?: boolean;
|
|
116
|
+
/** Token image URL */
|
|
117
|
+
image?: string;
|
|
118
|
+
/** Token description */
|
|
119
|
+
description?: string;
|
|
120
|
+
/** Current USD prices */
|
|
121
|
+
currentPrices?: WrappableTokenPrices;
|
|
122
|
+
}
|
|
123
|
+
/**
|
|
124
|
+
* Options for fetching wrappable tokens (metadata only, no balance)
|
|
125
|
+
*/
|
|
126
|
+
export interface FetchWrappableTokensOptions {
|
|
127
|
+
/** Pagination offset (default: 0) */
|
|
128
|
+
offset?: number;
|
|
129
|
+
/** Results per page (max: 1000, default: 1000) */
|
|
130
|
+
limit?: number;
|
|
131
|
+
}
|
|
132
|
+
/**
|
|
133
|
+
* Result of fetching wrappable tokens (metadata only, no balance)
|
|
134
|
+
*/
|
|
135
|
+
export interface FetchWrappableTokensResult {
|
|
136
|
+
/** Array of wrappable tokens */
|
|
137
|
+
tokens: WrappableToken[];
|
|
138
|
+
/** Timestamp when data was fetched */
|
|
139
|
+
fetchedAt: number;
|
|
140
|
+
/** Number of tokens returned */
|
|
141
|
+
tokenCount: number;
|
|
142
|
+
}
|
|
143
|
+
/**
|
|
144
|
+
* Options for getting a wrappable token by tokenId
|
|
145
|
+
*/
|
|
146
|
+
export interface GetWrappableTokenOptions {
|
|
147
|
+
/**
|
|
148
|
+
* Token identifier in flexible format.
|
|
149
|
+
*
|
|
150
|
+
* Accepts:
|
|
151
|
+
* - Pipe-delimited string: "$MUSIC|Unit|none|none"
|
|
152
|
+
* - TokenClassKey object: { collection: '$MUSIC', category: 'Unit', type: 'none', additionalKey: 'none' }
|
|
153
|
+
*
|
|
154
|
+
* @example "$MUSIC|Unit|none|none"
|
|
155
|
+
* @example { collection: '$MUSIC', category: 'Unit', type: 'none', additionalKey: 'none' }
|
|
156
|
+
*/
|
|
157
|
+
tokenId: TokenId;
|
|
158
|
+
}
|
|
159
|
+
/**
|
|
160
|
+
* Result of checking if a token is wrappable
|
|
161
|
+
*/
|
|
162
|
+
export interface IsTokenWrappableResult {
|
|
163
|
+
/** Whether the token is wrappable */
|
|
164
|
+
isWrappable: boolean;
|
|
165
|
+
/** The queried token's stringified TokenClassKey */
|
|
166
|
+
tokenId: string;
|
|
167
|
+
/** Counterpart token's stringified TokenClassKey (if wrappable) */
|
|
168
|
+
wrapCounterpart?: string;
|
|
169
|
+
}
|
|
170
|
+
/**
|
|
171
|
+
* Cache statistics for wrappable tokens
|
|
172
|
+
*/
|
|
173
|
+
export interface WrappableTokenCacheStats {
|
|
174
|
+
/** Number of tokens in cache */
|
|
175
|
+
tokenCount: number;
|
|
176
|
+
/** Whether cache is populated */
|
|
177
|
+
isPopulated: boolean;
|
|
178
|
+
/** Timestamp when cache was last updated */
|
|
179
|
+
lastFetchedAt: number | null;
|
|
180
|
+
}
|
|
181
|
+
/**
|
|
182
|
+
* Options for wrapping a token (e.g., MUSIC → GMUSIC)
|
|
183
|
+
*
|
|
184
|
+
* Wrapping transfers a token from its native channel to the asset channel,
|
|
185
|
+
* converting it to its wrapped counterpart. This is required for tokens
|
|
186
|
+
* like MUSIC to be traded on the DEX.
|
|
187
|
+
*
|
|
188
|
+
* @example
|
|
189
|
+
* ```typescript
|
|
190
|
+
* const result = await sdk.wrapToken({
|
|
191
|
+
* tokenId: 'MUSIC',
|
|
192
|
+
* amount: '100.5',
|
|
193
|
+
* });
|
|
194
|
+
* ```
|
|
195
|
+
*/
|
|
196
|
+
export interface WrapTokenOptions {
|
|
197
|
+
/**
|
|
198
|
+
* Token to wrap (source token on native channel).
|
|
199
|
+
*
|
|
200
|
+
* Accepts:
|
|
201
|
+
* - Symbol: "MUSIC"
|
|
202
|
+
* - Pipe-delimited: "$MUSIC|Unit|none|none"
|
|
203
|
+
* - TokenClassKey object: { collection: '$MUSIC', ... }
|
|
204
|
+
*/
|
|
205
|
+
tokenId: TokenId;
|
|
206
|
+
/** Amount to wrap (decimal string, e.g., "100.5") */
|
|
207
|
+
amount: string;
|
|
208
|
+
/** Optional recipient address (defaults to sender) */
|
|
209
|
+
recipient?: string;
|
|
210
|
+
/** Optional memo for the transaction */
|
|
211
|
+
memo?: string;
|
|
212
|
+
}
|
|
213
|
+
/**
|
|
214
|
+
* Options for unwrapping a token (e.g., GMUSIC → MUSIC)
|
|
215
|
+
*
|
|
216
|
+
* Unwrapping transfers a token from the asset channel back to its native
|
|
217
|
+
* channel, converting it from the wrapped version to the original.
|
|
218
|
+
*
|
|
219
|
+
* @example
|
|
220
|
+
* ```typescript
|
|
221
|
+
* const result = await sdk.unwrapToken({
|
|
222
|
+
* tokenId: 'GMUSIC',
|
|
223
|
+
* amount: '50',
|
|
224
|
+
* });
|
|
225
|
+
* ```
|
|
226
|
+
*/
|
|
227
|
+
export interface UnwrapTokenOptions {
|
|
228
|
+
/**
|
|
229
|
+
* Token to unwrap (wrapped token on asset channel).
|
|
230
|
+
*
|
|
231
|
+
* Accepts:
|
|
232
|
+
* - Symbol: "GMUSIC"
|
|
233
|
+
* - Pipe-delimited: "$GMUSIC|Unit|none|none"
|
|
234
|
+
* - TokenClassKey object: { collection: '$GMUSIC', ... }
|
|
235
|
+
*/
|
|
236
|
+
tokenId: TokenId;
|
|
237
|
+
/** Amount to unwrap (decimal string, e.g., "50") */
|
|
238
|
+
amount: string;
|
|
239
|
+
/** Optional recipient address (defaults to sender) */
|
|
240
|
+
recipient?: string;
|
|
241
|
+
/** Optional memo for the transaction */
|
|
242
|
+
memo?: string;
|
|
243
|
+
}
|
|
244
|
+
/**
|
|
245
|
+
* Result of a wrap or unwrap operation
|
|
246
|
+
*/
|
|
247
|
+
export interface WrapUnwrapResult {
|
|
248
|
+
/** Whether the operation succeeded */
|
|
249
|
+
success: boolean;
|
|
250
|
+
/** Transaction hash/ID for tracking */
|
|
251
|
+
transactionId?: string;
|
|
252
|
+
/** Source token symbol (e.g., "MUSIC" for wrap, "GMUSIC" for unwrap) */
|
|
253
|
+
fromToken: string;
|
|
254
|
+
/** Destination token symbol (e.g., "GMUSIC" for wrap, "MUSIC" for unwrap) */
|
|
255
|
+
toToken: string;
|
|
256
|
+
/** Amount transferred (decimal string) */
|
|
257
|
+
amount: string;
|
|
258
|
+
/** Source channel name (e.g., "music", "asset") */
|
|
259
|
+
fromChannel: string;
|
|
260
|
+
/** Destination channel name (e.g., "asset", "music") */
|
|
261
|
+
toChannel: string;
|
|
262
|
+
/** Fee paid for the operation (if any) */
|
|
263
|
+
fee?: string;
|
|
264
|
+
/** Timestamp when the operation completed (epoch ms) */
|
|
265
|
+
completedAt?: number;
|
|
266
|
+
/** Error message if operation failed */
|
|
267
|
+
error?: string;
|
|
268
|
+
}
|
|
269
|
+
/**
|
|
270
|
+
* Fee estimation for wrap/unwrap operations
|
|
271
|
+
*
|
|
272
|
+
* Wrap and unwrap operations may have different fee authorization types:
|
|
273
|
+
* - Wrap (→ asset): Uses `cross_channel_authorization` on source channel
|
|
274
|
+
* - Unwrap (→ native): Uses `automatic` authorization on asset channel
|
|
275
|
+
*/
|
|
276
|
+
export interface WrapUnwrapFeeEstimate {
|
|
277
|
+
/** Estimated fee amount (decimal string) */
|
|
278
|
+
fee: string;
|
|
279
|
+
/** Fee token symbol (usually "GALA") */
|
|
280
|
+
feeToken: string;
|
|
281
|
+
/** Fee authorization type used by the backend */
|
|
282
|
+
authorizationType: 'cross_channel_authorization' | 'automatic';
|
|
283
|
+
/** Channel where the fee is authorized/charged */
|
|
284
|
+
feeChannel: string;
|
|
285
|
+
}
|
|
286
|
+
/**
|
|
287
|
+
* Status of a wrap/unwrap operation
|
|
288
|
+
*/
|
|
289
|
+
export type WrapUnwrapStatus = 'pending' | 'processing' | 'completed' | 'failed';
|
|
290
|
+
/**
|
|
291
|
+
* Extended result with status polling information
|
|
292
|
+
*/
|
|
293
|
+
export interface WrapUnwrapStatusResult extends WrapUnwrapResult {
|
|
294
|
+
/** Current status of the operation */
|
|
295
|
+
status: WrapUnwrapStatus;
|
|
296
|
+
/** Number of confirmations (if applicable) */
|
|
297
|
+
confirmations?: number;
|
|
298
|
+
/** Estimated time remaining in ms (if available) */
|
|
299
|
+
estimatedTimeRemainingMs?: number;
|
|
300
|
+
}
|
|
301
|
+
//# sourceMappingURL=wrappable-token.dto.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"wrappable-token.dto.d.ts","sourceRoot":"","sources":["../../../src/types/wrappable-token.dto.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,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O,CAAC;IACjB,uCAAuC;IACvC,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,wEAAwE;IACxE,SAAS,EAAE,MAAM,CAAC;IAClB,6EAA6E;IAC7E,OAAO,EAAE,MAAM,CAAC;IAChB,0CAA0C;IAC1C,MAAM,EAAE,MAAM,CAAC;IACf,mDAAmD;IACnD,WAAW,EAAE,MAAM,CAAC;IACpB,wDAAwD;IACxD,SAAS,EAAE,MAAM,CAAC;IAClB,0CAA0C;IAC1C,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,wDAAwD;IACxD,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,wCAAwC;IACxC,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED;;;;;;GAMG;AACH,MAAM,WAAW,qBAAqB;IACpC,4CAA4C;IAC5C,GAAG,EAAE,MAAM,CAAC;IACZ,wCAAwC;IACxC,QAAQ,EAAE,MAAM,CAAC;IACjB,iDAAiD;IACjD,iBAAiB,EAAE,6BAA6B,GAAG,WAAW,CAAC;IAC/D,kDAAkD;IAClD,UAAU,EAAE,MAAM,CAAC;CACpB;AAED;;GAEG;AACH,MAAM,MAAM,gBAAgB,GACxB,SAAS,GACT,YAAY,GACZ,WAAW,GACX,QAAQ,CAAC;AAEb;;GAEG;AACH,MAAM,WAAW,sBAAuB,SAAQ,gBAAgB;IAC9D,sCAAsC;IACtC,MAAM,EAAE,gBAAgB,CAAC;IACzB,8CAA8C;IAC9C,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,oDAAoD;IACpD,wBAAwB,CAAC,EAAE,MAAM,CAAC;CACnC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gala-chain/launchpad-sdk",
|
|
3
|
-
"version": "4.0.17-beta.
|
|
3
|
+
"version": "4.0.17-beta.10",
|
|
4
4
|
"description": "TypeScript SDK for Gala Launchpad Backend API - 100+ public methods with 373+ fully documented APIs supporting optional wallet (read-only and full-access modes). Production-ready DeFi token launchpad integration with AgentConfig setup, GalaChain trading, GSwap DEX integration, price history, token creation, DEX pool discovery, WebSocket event watchers, and comprehensive user operations. Multi-format output (ESM, CJS, UMD).",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/index.esm.js",
|
|
@@ -66,6 +66,7 @@
|
|
|
66
66
|
"demo:utilities:balances": "tsx examples/utilities/balances.ts",
|
|
67
67
|
"demo:utilities:key-derivation": "tsx examples/utilities/key-derivation.ts",
|
|
68
68
|
"demo:utilities:price-history": "tsx examples/utilities/price-history.ts",
|
|
69
|
+
"demo:utilities:wrappable-tokens": "tsx examples/utilities/wrappable-tokens.ts",
|
|
69
70
|
"demo:dex": "tsx examples/dex/swap-workflow.ts",
|
|
70
71
|
"demo:dex:pools": "tsx examples/dex/pool-discovery.ts",
|
|
71
72
|
"demo:dex:pricing": "tsx examples/dex/pools-with-pricing.ts",
|
|
@@ -115,6 +116,10 @@
|
|
|
115
116
|
"demo:bridge:sol:roundtrip": "tsx examples/bridge/solana-roundtrip.ts",
|
|
116
117
|
"demo:bridge:balances": "tsx examples/bridge/wallet-balances.ts",
|
|
117
118
|
"demo:bridge:bridgeable": "tsx examples/bridge/bridgeable-tokens.ts",
|
|
119
|
+
"demo:bridge:tx-status": "tsx examples/bridge/transaction-status.ts",
|
|
120
|
+
"demo:wrap": "tsx examples/bridge/wrap-unwrap.ts",
|
|
121
|
+
"demo:wrap:discovery": "tsx examples/bridge/wrap-discovery.ts",
|
|
122
|
+
"demo:wrap:fees": "tsx examples/bridge/wrap-fee-estimation.ts",
|
|
118
123
|
"test:demos:core": "npm run demo && npm run demo:read-only && npm run demo:authenticated && npm run demo:privatekey-override",
|
|
119
124
|
"test:demos:dex": "npm run demo:dex:pools && npm run demo:dex:pricing && npm run demo:dex:quotes && npm run demo:dex && npm run demo:dex:roundtrip",
|
|
120
125
|
"test:demos:liquidity": "npm run demo:liquidity:all",
|