@unifold/core 0.1.11
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 +78 -0
- package/dist/index.d.mts +384 -0
- package/dist/index.d.ts +384 -0
- package/dist/index.js +420 -0
- package/dist/index.mjs +375 -0
- package/package.json +44 -0
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,384 @@
|
|
|
1
|
+
declare function setApiConfig(config: {
|
|
2
|
+
baseUrl?: string;
|
|
3
|
+
publishableKey?: string;
|
|
4
|
+
defaultConfig?: {
|
|
5
|
+
destinationChainId?: string;
|
|
6
|
+
destinationTokenAddress?: string;
|
|
7
|
+
recipientAddress?: string;
|
|
8
|
+
};
|
|
9
|
+
}): void;
|
|
10
|
+
declare function getApiBaseUrl(): string;
|
|
11
|
+
/**
|
|
12
|
+
* Build an icon URL using the API base URL
|
|
13
|
+
* Converts relative paths like "/icons/networks/ethereum.svg" to full URLs
|
|
14
|
+
* like "https://api.unifold.io/api/public/icons/networks/ethereum.svg"
|
|
15
|
+
*/
|
|
16
|
+
declare function getIconUrl(iconPath: string): string;
|
|
17
|
+
/**
|
|
18
|
+
* Build an icon URL using a custom CDN base URL
|
|
19
|
+
* Converts relative paths like "/icons/networks/ethereum.svg" to full CDN URLs
|
|
20
|
+
* Falls back to getIconUrl if no CDN URL is provided
|
|
21
|
+
*/
|
|
22
|
+
declare function getIconUrlWithCdn(iconPath: string, assetCdnUrl?: string): string;
|
|
23
|
+
interface Wallet {
|
|
24
|
+
id: string;
|
|
25
|
+
chain_type: "ethereum" | "solana" | "bitcoin";
|
|
26
|
+
address_type: string | null;
|
|
27
|
+
address: string;
|
|
28
|
+
destination_chain_type: string;
|
|
29
|
+
destination_chain_id: string;
|
|
30
|
+
destination_token_address: string;
|
|
31
|
+
recipient_address: string;
|
|
32
|
+
is_primary: boolean;
|
|
33
|
+
}
|
|
34
|
+
interface DepositAddressResponse {
|
|
35
|
+
data: Wallet[];
|
|
36
|
+
}
|
|
37
|
+
interface CreateDepositAddressRequest {
|
|
38
|
+
external_user_id: string;
|
|
39
|
+
destination_chain_type: string;
|
|
40
|
+
destination_chain_id: string;
|
|
41
|
+
destination_token_address: string;
|
|
42
|
+
recipient_address: string;
|
|
43
|
+
client_metadata?: Record<string, unknown>;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Create deposit addresses for a user
|
|
47
|
+
* @param overrides - Override default configuration (external_user_id, recipient_address, etc.)
|
|
48
|
+
* @param publishableKey - Optional publishable key, defaults to configured key
|
|
49
|
+
*/
|
|
50
|
+
declare function createDepositAddress(overrides?: Partial<CreateDepositAddressRequest>, publishableKey?: string): Promise<DepositAddressResponse>;
|
|
51
|
+
/**
|
|
52
|
+
* Get wallet address for a specific chain type
|
|
53
|
+
*/
|
|
54
|
+
declare function getWalletByChainType(wallets: Wallet[], chainType: "ethereum" | "solana" | "bitcoin"): Wallet | undefined;
|
|
55
|
+
interface AutoSwapRequest {
|
|
56
|
+
wallet_id: string;
|
|
57
|
+
origin_currency: string;
|
|
58
|
+
}
|
|
59
|
+
declare enum ExecutionStatus {
|
|
60
|
+
DELAYED = "delayed",
|
|
61
|
+
FAILED = "failed",
|
|
62
|
+
PENDING = "pending",
|
|
63
|
+
REFUNDED = "refunded",
|
|
64
|
+
SUCCEEDED = "succeeded",
|
|
65
|
+
WAITING = "waiting"
|
|
66
|
+
}
|
|
67
|
+
interface IconUrl {
|
|
68
|
+
url: string;
|
|
69
|
+
format: "svg" | "png";
|
|
70
|
+
}
|
|
71
|
+
interface AutoSwapResponse {
|
|
72
|
+
id: string;
|
|
73
|
+
project_id: string;
|
|
74
|
+
user_id: string;
|
|
75
|
+
deposit_wallet_id: string;
|
|
76
|
+
owner_type?: string;
|
|
77
|
+
owner_id?: string;
|
|
78
|
+
transaction_hash: string;
|
|
79
|
+
recipient_address: string;
|
|
80
|
+
provider: string;
|
|
81
|
+
provider_id: string;
|
|
82
|
+
source_chain_type: string;
|
|
83
|
+
source_chain_id: string;
|
|
84
|
+
source_token_address: string;
|
|
85
|
+
destination_chain_type: string;
|
|
86
|
+
destination_chain_id: string;
|
|
87
|
+
destination_token_address: string;
|
|
88
|
+
source_amount_base_unit: string;
|
|
89
|
+
source_amount_usd?: string;
|
|
90
|
+
destination_amount_base_unit: string;
|
|
91
|
+
provider_metadata: unknown;
|
|
92
|
+
created_at?: string;
|
|
93
|
+
updated_at?: string;
|
|
94
|
+
explorer_url: string;
|
|
95
|
+
destination_explorer_url: string | null;
|
|
96
|
+
destination_transaction_hashes: string[];
|
|
97
|
+
status: ExecutionStatus;
|
|
98
|
+
source_token_metadata?: {
|
|
99
|
+
icon_url: string;
|
|
100
|
+
icon_urls?: IconUrl[];
|
|
101
|
+
};
|
|
102
|
+
destination_token_metadata?: {
|
|
103
|
+
icon_url: string;
|
|
104
|
+
icon_urls?: IconUrl[];
|
|
105
|
+
};
|
|
106
|
+
deposit_wallet?: {
|
|
107
|
+
id: string;
|
|
108
|
+
chain_type: string;
|
|
109
|
+
address_type: string | null;
|
|
110
|
+
address: string;
|
|
111
|
+
is_primary: boolean;
|
|
112
|
+
created_at: string;
|
|
113
|
+
updated_at: string;
|
|
114
|
+
last_used_at: string | null;
|
|
115
|
+
};
|
|
116
|
+
source_currency?: string;
|
|
117
|
+
destination_currency?: string;
|
|
118
|
+
}
|
|
119
|
+
declare const SOLANA_USDC_ADDRESS = "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v";
|
|
120
|
+
interface QueryExecutionsRequest {
|
|
121
|
+
external_user_id: string;
|
|
122
|
+
}
|
|
123
|
+
interface QueryExecutionsResponse {
|
|
124
|
+
data: AutoSwapResponse[];
|
|
125
|
+
}
|
|
126
|
+
/**
|
|
127
|
+
* Query all direct executions for a user
|
|
128
|
+
* Returns ALL executions - filter client-side for new ones
|
|
129
|
+
* @param externalUserId - External user ID
|
|
130
|
+
* @param publishableKey - Optional publishable key, defaults to configured key
|
|
131
|
+
*/
|
|
132
|
+
declare function queryExecutions(externalUserId: string, publishableKey?: string): Promise<QueryExecutionsResponse>;
|
|
133
|
+
interface SupportedChain {
|
|
134
|
+
chain_id: string;
|
|
135
|
+
chain_name: string;
|
|
136
|
+
chain_type: string;
|
|
137
|
+
icon_url: string;
|
|
138
|
+
token_address: string;
|
|
139
|
+
estimated_price_impact_percent: number;
|
|
140
|
+
max_slippage_percent: number;
|
|
141
|
+
estimated_processing_time: number | null;
|
|
142
|
+
minimum_deposit_amount_usd: number;
|
|
143
|
+
}
|
|
144
|
+
interface SupportedToken {
|
|
145
|
+
symbol: string;
|
|
146
|
+
name: string;
|
|
147
|
+
icon_url: string;
|
|
148
|
+
is_newly_added: boolean;
|
|
149
|
+
chains: SupportedChain[];
|
|
150
|
+
}
|
|
151
|
+
interface SupportedDepositTokensResponse {
|
|
152
|
+
data: SupportedToken[];
|
|
153
|
+
}
|
|
154
|
+
/**
|
|
155
|
+
* Get supported deposit tokens
|
|
156
|
+
* @param publishableKey - Optional publishable key, defaults to configured key
|
|
157
|
+
*/
|
|
158
|
+
declare function getSupportedDepositTokens(publishableKey?: string): Promise<SupportedDepositTokensResponse>;
|
|
159
|
+
interface MeldQuote {
|
|
160
|
+
transaction_type: string;
|
|
161
|
+
payment_method_type: string;
|
|
162
|
+
source_amount: number;
|
|
163
|
+
source_amount_without_fees: number;
|
|
164
|
+
fiat_amount_without_fees: number;
|
|
165
|
+
destination_amount_without_fees: number | null;
|
|
166
|
+
source_currency_code: string;
|
|
167
|
+
country_code: string;
|
|
168
|
+
total_fee: number;
|
|
169
|
+
network_fee: number;
|
|
170
|
+
transaction_fee: number;
|
|
171
|
+
destination_amount: number;
|
|
172
|
+
destination_currency_code: string;
|
|
173
|
+
exchange_rate: number;
|
|
174
|
+
customer_score: number;
|
|
175
|
+
service_provider: string;
|
|
176
|
+
service_provider_display_name: string;
|
|
177
|
+
institution_name: string | null;
|
|
178
|
+
low_kyc: boolean | null;
|
|
179
|
+
partner_fee: number | null;
|
|
180
|
+
icon_url: string;
|
|
181
|
+
}
|
|
182
|
+
interface MeldQuotesRequest {
|
|
183
|
+
country_code: string;
|
|
184
|
+
destination_currency_code: string;
|
|
185
|
+
source_amount: string;
|
|
186
|
+
source_currency_code: string;
|
|
187
|
+
}
|
|
188
|
+
interface MeldQuotesResponse {
|
|
189
|
+
data: MeldQuote[];
|
|
190
|
+
}
|
|
191
|
+
/**
|
|
192
|
+
* Get Meld onramp quotes
|
|
193
|
+
* @param request - Meld quotes request
|
|
194
|
+
* @param publishableKey - Optional publishable key, defaults to configured key
|
|
195
|
+
*/
|
|
196
|
+
declare function getMeldQuotes(request: MeldQuotesRequest, publishableKey?: string): Promise<MeldQuotesResponse>;
|
|
197
|
+
interface MeldSessionRequest {
|
|
198
|
+
service_provider: string;
|
|
199
|
+
country_code: string;
|
|
200
|
+
destination_currency_code: string;
|
|
201
|
+
source_currency_code: string;
|
|
202
|
+
wallet_address: string;
|
|
203
|
+
source_amount: string;
|
|
204
|
+
}
|
|
205
|
+
interface MeldSessionResponse {
|
|
206
|
+
id: string;
|
|
207
|
+
external_session_id: string | null;
|
|
208
|
+
external_customer_id: string | null;
|
|
209
|
+
customer_id: string;
|
|
210
|
+
widget_url: string;
|
|
211
|
+
service_provider_widget_url: string;
|
|
212
|
+
token: string;
|
|
213
|
+
}
|
|
214
|
+
/**
|
|
215
|
+
* Create a Meld onramp session
|
|
216
|
+
* @param request - Meld session request
|
|
217
|
+
* @param publishableKey - Optional publishable key, defaults to configured key
|
|
218
|
+
*/
|
|
219
|
+
declare function createMeldSession(request: MeldSessionRequest, publishableKey?: string): Promise<MeldSessionResponse>;
|
|
220
|
+
/**
|
|
221
|
+
* Get the preferred icon URL from an array of icon URLs
|
|
222
|
+
* @param iconUrls - Array of icon URLs with format information
|
|
223
|
+
* @param preferredFormat - Preferred format ("svg" or "png"), defaults to "svg"
|
|
224
|
+
* @returns The URL string for the preferred format, or first available if preferred not found
|
|
225
|
+
*/
|
|
226
|
+
declare function getPreferredIconUrl(iconUrls: IconUrl[] | undefined, preferredFormat?: "svg" | "png"): string | undefined;
|
|
227
|
+
interface FiatCurrency {
|
|
228
|
+
currency_code: string;
|
|
229
|
+
name: string;
|
|
230
|
+
icon_url: string;
|
|
231
|
+
icon_urls?: IconUrl[];
|
|
232
|
+
}
|
|
233
|
+
interface FiatCurrenciesResponse {
|
|
234
|
+
data: FiatCurrency[];
|
|
235
|
+
preferred: string[];
|
|
236
|
+
}
|
|
237
|
+
/**
|
|
238
|
+
* Get supported fiat currencies
|
|
239
|
+
* @param publishableKey - Optional publishable key, defaults to configured key
|
|
240
|
+
*/
|
|
241
|
+
declare function getFiatCurrencies(publishableKey?: string): Promise<FiatCurrenciesResponse>;
|
|
242
|
+
interface TokenChainIconUrl {
|
|
243
|
+
url: string;
|
|
244
|
+
format: string;
|
|
245
|
+
}
|
|
246
|
+
interface TokenChain {
|
|
247
|
+
chain_id: string;
|
|
248
|
+
chain_name: string;
|
|
249
|
+
chain_type: string;
|
|
250
|
+
icon_url: string;
|
|
251
|
+
icon_urls: TokenChainIconUrl[];
|
|
252
|
+
}
|
|
253
|
+
interface TokenChainsResponse {
|
|
254
|
+
data: TokenChain[];
|
|
255
|
+
}
|
|
256
|
+
/**
|
|
257
|
+
* Get all supported token chains
|
|
258
|
+
* This is a public endpoint that doesn't require authentication
|
|
259
|
+
*/
|
|
260
|
+
declare function getTokenChains(): Promise<TokenChainsResponse>;
|
|
261
|
+
/**
|
|
262
|
+
* Find a chain name by chain_id or chain_type
|
|
263
|
+
* @param chains - Array of TokenChain objects
|
|
264
|
+
* @param chainType - The chain type (e.g., "ethereum", "solana")
|
|
265
|
+
* @param chainId - The chain ID (e.g., "1", "137")
|
|
266
|
+
* @returns The chain name or a fallback value
|
|
267
|
+
*/
|
|
268
|
+
declare function getChainName(chains: TokenChain[], chainType: string, chainId: string): string;
|
|
269
|
+
interface FeaturedToken {
|
|
270
|
+
name: string;
|
|
271
|
+
position: number;
|
|
272
|
+
icon_urls: IconUrl[];
|
|
273
|
+
}
|
|
274
|
+
interface PaymentNetwork {
|
|
275
|
+
name: string;
|
|
276
|
+
icon_urls: IconUrl[];
|
|
277
|
+
}
|
|
278
|
+
interface ProjectConfigResponse {
|
|
279
|
+
asset_cdn_url: string;
|
|
280
|
+
transfer_crypto: {
|
|
281
|
+
networks: FeaturedToken[];
|
|
282
|
+
};
|
|
283
|
+
payment_networks: {
|
|
284
|
+
networks: PaymentNetwork[];
|
|
285
|
+
};
|
|
286
|
+
}
|
|
287
|
+
/**
|
|
288
|
+
* Get project configuration
|
|
289
|
+
* @param publishableKey - Optional publishable key, defaults to configured key
|
|
290
|
+
*/
|
|
291
|
+
declare function getProjectConfig(publishableKey?: string): Promise<ProjectConfigResponse>;
|
|
292
|
+
|
|
293
|
+
/**
|
|
294
|
+
* User IP information interface
|
|
295
|
+
*/
|
|
296
|
+
interface UserIpInfo {
|
|
297
|
+
alpha2: string;
|
|
298
|
+
state?: string;
|
|
299
|
+
}
|
|
300
|
+
/**
|
|
301
|
+
* Hook to fetch user's IP-based location information
|
|
302
|
+
*
|
|
303
|
+
* Uses ipapi.co to detect the user's country and state.
|
|
304
|
+
*
|
|
305
|
+
* The result is cached in-memory using React Query:
|
|
306
|
+
* - Data persists for the entire browser session
|
|
307
|
+
* - Shared across all components using this hook
|
|
308
|
+
* - Reduces API calls and protects against rate limiting
|
|
309
|
+
*
|
|
310
|
+
* @returns User IP information including country code
|
|
311
|
+
*/
|
|
312
|
+
declare function useUserIp(): {
|
|
313
|
+
userIpInfo: UserIpInfo | undefined;
|
|
314
|
+
isLoading: boolean;
|
|
315
|
+
error: Error | null;
|
|
316
|
+
};
|
|
317
|
+
|
|
318
|
+
declare const i18n: {
|
|
319
|
+
transferCrypto: {
|
|
320
|
+
priceImpact: {
|
|
321
|
+
label: string;
|
|
322
|
+
tooltip: string;
|
|
323
|
+
finalCost: string;
|
|
324
|
+
};
|
|
325
|
+
slippage: {
|
|
326
|
+
label: string;
|
|
327
|
+
auto: string;
|
|
328
|
+
tooltip: string;
|
|
329
|
+
finalCost: string;
|
|
330
|
+
};
|
|
331
|
+
processingTime: {
|
|
332
|
+
label: string;
|
|
333
|
+
lessThanMinutes: string;
|
|
334
|
+
lessThanHours: string;
|
|
335
|
+
};
|
|
336
|
+
minDeposit: {
|
|
337
|
+
label: string;
|
|
338
|
+
tooltip: string;
|
|
339
|
+
};
|
|
340
|
+
help: {
|
|
341
|
+
needHelp: string;
|
|
342
|
+
contactSupport: string;
|
|
343
|
+
};
|
|
344
|
+
terms: {
|
|
345
|
+
termsApply: string;
|
|
346
|
+
};
|
|
347
|
+
supportedToken: string;
|
|
348
|
+
supportedChain: string;
|
|
349
|
+
depositAddress: {
|
|
350
|
+
label: string;
|
|
351
|
+
tooltip: string;
|
|
352
|
+
};
|
|
353
|
+
copyAddress: string;
|
|
354
|
+
copied: string;
|
|
355
|
+
loading: string;
|
|
356
|
+
loadingQRCode: string;
|
|
357
|
+
noAddressAvailable: string;
|
|
358
|
+
noChainsAvailable: string;
|
|
359
|
+
};
|
|
360
|
+
depositModal: {
|
|
361
|
+
transferCrypto: {
|
|
362
|
+
title: string;
|
|
363
|
+
subtitle: string;
|
|
364
|
+
};
|
|
365
|
+
depositWithCard: {
|
|
366
|
+
title: string;
|
|
367
|
+
subtitle: string;
|
|
368
|
+
};
|
|
369
|
+
quotes: string;
|
|
370
|
+
};
|
|
371
|
+
buyWithCard: {
|
|
372
|
+
onramp: {
|
|
373
|
+
completeTransaction: string;
|
|
374
|
+
canCloseModal: string;
|
|
375
|
+
youUse: string;
|
|
376
|
+
youBuy: string;
|
|
377
|
+
youReceive: string;
|
|
378
|
+
intentAddressNote: string;
|
|
379
|
+
};
|
|
380
|
+
};
|
|
381
|
+
};
|
|
382
|
+
type I18nStrings = typeof i18n;
|
|
383
|
+
|
|
384
|
+
export { type AutoSwapRequest, type AutoSwapResponse, type CreateDepositAddressRequest, type DepositAddressResponse, ExecutionStatus, type FeaturedToken, type FiatCurrenciesResponse, type FiatCurrency, type I18nStrings, type IconUrl, type MeldQuote, type MeldQuotesRequest, type MeldQuotesResponse, type MeldSessionRequest, type MeldSessionResponse, type PaymentNetwork, type ProjectConfigResponse, type QueryExecutionsRequest, type QueryExecutionsResponse, SOLANA_USDC_ADDRESS, type SupportedChain, type SupportedDepositTokensResponse, type SupportedToken, type TokenChain, type TokenChainIconUrl, type TokenChainsResponse, type UserIpInfo, type Wallet, createDepositAddress, createMeldSession, getApiBaseUrl, getChainName, getFiatCurrencies, getIconUrl, getIconUrlWithCdn, getMeldQuotes, getPreferredIconUrl, getProjectConfig, getSupportedDepositTokens, getTokenChains, getWalletByChainType, i18n, queryExecutions, setApiConfig, useUserIp };
|