@unifold/core 0.1.19 → 0.1.21
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/dist/index.d.mts +126 -48
- package/dist/index.d.ts +126 -48
- package/dist/index.js +102 -26
- package/dist/index.mjs +97 -24
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -22,7 +22,7 @@ declare function getIconUrl(iconPath: string): string;
|
|
|
22
22
|
declare function getIconUrlWithCdn(iconPath: string, assetCdnUrl?: string): string;
|
|
23
23
|
interface Wallet {
|
|
24
24
|
id: string;
|
|
25
|
-
chain_type: "ethereum" | "solana" | "bitcoin";
|
|
25
|
+
chain_type: "ethereum" | "solana" | "bitcoin" | "algorand";
|
|
26
26
|
address_type: string | null;
|
|
27
27
|
address: string;
|
|
28
28
|
destination_chain_type: string;
|
|
@@ -51,7 +51,7 @@ declare function createDepositAddress(overrides?: Partial<CreateDepositAddressRe
|
|
|
51
51
|
/**
|
|
52
52
|
* Get wallet address for a specific chain type
|
|
53
53
|
*/
|
|
54
|
-
declare function getWalletByChainType(wallets: Wallet[], chainType: "ethereum" | "solana" | "bitcoin"): Wallet | undefined;
|
|
54
|
+
declare function getWalletByChainType(wallets: Wallet[], chainType: "ethereum" | "solana" | "bitcoin" | "algorand"): Wallet | undefined;
|
|
55
55
|
interface AutoSwapRequest {
|
|
56
56
|
wallet_id: string;
|
|
57
57
|
origin_currency: string;
|
|
@@ -157,91 +157,169 @@ interface SupportedDepositTokensResponse {
|
|
|
157
157
|
* Get supported deposit tokens
|
|
158
158
|
* @param publishableKey - Optional publishable key, defaults to configured key
|
|
159
159
|
*/
|
|
160
|
-
declare function getSupportedDepositTokens(publishableKey?: string
|
|
161
|
-
|
|
160
|
+
declare function getSupportedDepositTokens(publishableKey?: string, options?: {
|
|
161
|
+
destination_token_address?: string;
|
|
162
|
+
destination_chain_id?: string;
|
|
163
|
+
destination_chain_type?: string;
|
|
164
|
+
}): Promise<SupportedDepositTokensResponse>;
|
|
165
|
+
interface TokenMetadata {
|
|
166
|
+
symbol: string;
|
|
167
|
+
name: string;
|
|
168
|
+
icon_url: string;
|
|
169
|
+
icon_urls: IconUrl[];
|
|
170
|
+
chain_name: string;
|
|
171
|
+
chain_type: string;
|
|
172
|
+
chain_id: string;
|
|
173
|
+
token_address: string;
|
|
174
|
+
decimals: number;
|
|
175
|
+
chain_icon_url: string;
|
|
176
|
+
chain_icon_urls: IconUrl[];
|
|
177
|
+
}
|
|
178
|
+
interface GetTokenMetadataRequest {
|
|
179
|
+
chain_type: string;
|
|
180
|
+
chain_id: string;
|
|
181
|
+
token_address: string;
|
|
182
|
+
}
|
|
183
|
+
/**
|
|
184
|
+
* Get token metadata for a specific token
|
|
185
|
+
* @param request - Token query parameters (chain_type, chain_id, token_address)
|
|
186
|
+
* @param publishableKey - Optional publishable key, defaults to configured key
|
|
187
|
+
*/
|
|
188
|
+
declare function getTokenMetadata(request: GetTokenMetadataRequest, publishableKey?: string): Promise<TokenMetadata | null>;
|
|
189
|
+
/**
|
|
190
|
+
* Get the preferred icon URL from an array of icon URLs
|
|
191
|
+
* @param iconUrls - Array of icon URLs with format information
|
|
192
|
+
* @param preferredFormat - Preferred format ("svg" or "png"), defaults to "svg"
|
|
193
|
+
* @returns The URL string for the preferred format, or first available if preferred not found
|
|
194
|
+
*/
|
|
195
|
+
declare function getPreferredIconUrl(iconUrls: IconUrl[] | undefined, preferredFormat?: "svg" | "png"): string | undefined;
|
|
196
|
+
interface FiatCurrency {
|
|
197
|
+
currency_code: string;
|
|
198
|
+
name: string;
|
|
199
|
+
icon_url: string;
|
|
200
|
+
icon_urls: IconUrl[];
|
|
201
|
+
country_codes: string[];
|
|
202
|
+
default_amount: number;
|
|
203
|
+
minimum_amount: number;
|
|
204
|
+
maximum_amount: number;
|
|
205
|
+
suggested_amounts: number[];
|
|
206
|
+
}
|
|
207
|
+
interface FiatCurrenciesResponse {
|
|
208
|
+
data: FiatCurrency[];
|
|
209
|
+
preferred: string[];
|
|
210
|
+
}
|
|
211
|
+
/**
|
|
212
|
+
* Get supported fiat currencies
|
|
213
|
+
* @param publishableKey - Optional publishable key, defaults to configured key
|
|
214
|
+
*/
|
|
215
|
+
declare function getFiatCurrencies(publishableKey?: string): Promise<FiatCurrenciesResponse>;
|
|
216
|
+
interface OnrampQuote {
|
|
162
217
|
transaction_type: string;
|
|
163
|
-
payment_method_type: string;
|
|
164
218
|
source_amount: number;
|
|
165
219
|
source_amount_without_fees: number;
|
|
166
220
|
fiat_amount_without_fees: number;
|
|
167
221
|
destination_amount_without_fees: number | null;
|
|
168
|
-
|
|
222
|
+
source_currency: string;
|
|
169
223
|
country_code: string;
|
|
170
224
|
total_fee: number;
|
|
171
225
|
network_fee: number;
|
|
172
226
|
transaction_fee: number;
|
|
173
227
|
destination_amount: number;
|
|
174
|
-
|
|
228
|
+
destination_currency: string;
|
|
229
|
+
destination_network: string;
|
|
175
230
|
exchange_rate: number;
|
|
231
|
+
payment_method_type: string;
|
|
176
232
|
customer_score: number;
|
|
177
233
|
service_provider: string;
|
|
178
234
|
service_provider_display_name: string;
|
|
235
|
+
icon_url: string;
|
|
236
|
+
icon_urls: IconUrl[];
|
|
179
237
|
institution_name: string | null;
|
|
180
|
-
low_kyc: boolean
|
|
238
|
+
low_kyc: boolean;
|
|
181
239
|
partner_fee: number | null;
|
|
182
|
-
icon_url: string;
|
|
183
240
|
}
|
|
184
|
-
interface
|
|
241
|
+
interface OnrampQuotesRequest {
|
|
185
242
|
country_code: string;
|
|
186
|
-
destination_currency_code: string;
|
|
187
243
|
source_amount: string;
|
|
188
|
-
|
|
244
|
+
source_currency: string;
|
|
245
|
+
destination_currency: string;
|
|
246
|
+
destination_network: string;
|
|
247
|
+
subdivision_code?: string;
|
|
189
248
|
}
|
|
190
|
-
interface
|
|
191
|
-
data:
|
|
249
|
+
interface OnrampQuotesResponse {
|
|
250
|
+
data: OnrampQuote[];
|
|
192
251
|
}
|
|
193
252
|
/**
|
|
194
|
-
* Get
|
|
195
|
-
* @param request -
|
|
253
|
+
* Get unified onramp quotes from all providers
|
|
254
|
+
* @param request - Onramp quotes request
|
|
196
255
|
* @param publishableKey - Optional publishable key, defaults to configured key
|
|
197
256
|
*/
|
|
198
|
-
declare function
|
|
199
|
-
interface
|
|
257
|
+
declare function getOnrampQuotes(request: OnrampQuotesRequest, publishableKey?: string): Promise<OnrampQuotesResponse>;
|
|
258
|
+
interface OnrampSessionRequest {
|
|
200
259
|
service_provider: string;
|
|
201
260
|
country_code: string;
|
|
202
|
-
|
|
203
|
-
source_currency_code: string;
|
|
204
|
-
wallet_address: string;
|
|
261
|
+
source_currency: string;
|
|
205
262
|
source_amount: string;
|
|
263
|
+
destination_currency: string;
|
|
264
|
+
destination_network: string;
|
|
265
|
+
wallet_address: string;
|
|
266
|
+
subdivision_code?: string;
|
|
267
|
+
redirect_url?: string;
|
|
206
268
|
}
|
|
207
|
-
interface
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
external_customer_id: string | null;
|
|
211
|
-
customer_id: string;
|
|
212
|
-
widget_url: string;
|
|
213
|
-
service_provider_widget_url: string;
|
|
214
|
-
token: string;
|
|
269
|
+
interface OnrampSessionResponse {
|
|
270
|
+
url: string;
|
|
271
|
+
service_provider: string;
|
|
215
272
|
}
|
|
216
273
|
/**
|
|
217
|
-
* Create a
|
|
218
|
-
* @param request -
|
|
274
|
+
* Create a unified onramp session
|
|
275
|
+
* @param request - Onramp session request
|
|
219
276
|
* @param publishableKey - Optional publishable key, defaults to configured key
|
|
220
277
|
*/
|
|
221
|
-
declare function
|
|
278
|
+
declare function createOnrampSession(request: OnrampSessionRequest, publishableKey?: string): Promise<OnrampSessionResponse>;
|
|
222
279
|
/**
|
|
223
|
-
*
|
|
224
|
-
*
|
|
225
|
-
* @param
|
|
226
|
-
* @
|
|
280
|
+
* Generate a URL for the sessions/start endpoint that redirects to the onramp provider.
|
|
281
|
+
* This is useful for avoiding popup blockers by opening the URL directly via anchor tag.
|
|
282
|
+
* @param request - Onramp session request (same parameters as createOnrampSession)
|
|
283
|
+
* @param publishableKey - Publishable key (required)
|
|
284
|
+
* @returns URL string that can be used in an anchor tag or window.open()
|
|
227
285
|
*/
|
|
228
|
-
declare function
|
|
229
|
-
interface
|
|
230
|
-
|
|
231
|
-
|
|
286
|
+
declare function getOnrampSessionStartUrl(request: OnrampSessionRequest, publishableKey: string): string;
|
|
287
|
+
interface DefaultTokenChain {
|
|
288
|
+
icon_url: string;
|
|
289
|
+
icon_urls: IconUrl[];
|
|
290
|
+
chain_id: string;
|
|
291
|
+
chain_name: string;
|
|
292
|
+
chain_type: string;
|
|
293
|
+
}
|
|
294
|
+
interface DefaultTokenMetadata {
|
|
232
295
|
icon_url: string;
|
|
233
|
-
icon_urls
|
|
234
|
-
|
|
296
|
+
icon_urls: IconUrl[];
|
|
297
|
+
decimals: number;
|
|
298
|
+
symbol: string;
|
|
299
|
+
name: string;
|
|
300
|
+
token_address: string;
|
|
301
|
+
chain_id: string;
|
|
302
|
+
chain_type: string;
|
|
303
|
+
chain_name: string;
|
|
304
|
+
chain: DefaultTokenChain;
|
|
235
305
|
}
|
|
236
|
-
interface
|
|
237
|
-
|
|
238
|
-
|
|
306
|
+
interface DefaultTokenResponse {
|
|
307
|
+
destination_network: string;
|
|
308
|
+
destination_currency: string;
|
|
309
|
+
destination_token_metadata: DefaultTokenMetadata;
|
|
239
310
|
}
|
|
240
311
|
/**
|
|
241
|
-
* Get
|
|
312
|
+
* Get default onramp token for a given token/chain combination
|
|
313
|
+
* @param params - Query parameters
|
|
242
314
|
* @param publishableKey - Optional publishable key, defaults to configured key
|
|
243
315
|
*/
|
|
244
|
-
declare function
|
|
316
|
+
declare function getDefaultOnrampToken(params: {
|
|
317
|
+
country_code?: string;
|
|
318
|
+
subdivision_code?: string;
|
|
319
|
+
token_address: string;
|
|
320
|
+
chain_id: string;
|
|
321
|
+
chain_type: string;
|
|
322
|
+
}, publishableKey?: string): Promise<DefaultTokenResponse>;
|
|
245
323
|
interface TokenChainIconUrl {
|
|
246
324
|
url: string;
|
|
247
325
|
format: string;
|
|
@@ -401,4 +479,4 @@ declare const i18n: {
|
|
|
401
479
|
};
|
|
402
480
|
type I18nStrings = typeof i18n;
|
|
403
481
|
|
|
404
|
-
export { type AutoSwapRequest, type AutoSwapResponse, type CreateDepositAddressRequest, type DepositAddressResponse, ExecutionStatus, type FeaturedToken, type FiatCurrenciesResponse, type FiatCurrency, type I18nStrings, type IconUrl, type IpAddressResponse, type
|
|
482
|
+
export { type AutoSwapRequest, type AutoSwapResponse, type CreateDepositAddressRequest, type DefaultTokenChain, type DefaultTokenMetadata, type DefaultTokenResponse, type DepositAddressResponse, ExecutionStatus, type FeaturedToken, type FiatCurrenciesResponse, type FiatCurrency, type I18nStrings, type IconUrl, type IpAddressResponse, type OnrampQuote, type OnrampQuotesRequest, type OnrampQuotesResponse, type OnrampSessionRequest, type OnrampSessionResponse, type PaymentNetwork, type ProjectConfigResponse, type QueryExecutionsRequest, type QueryExecutionsResponse, SOLANA_USDC_ADDRESS, type SupportedChain, type SupportedDepositTokensResponse, type SupportedToken, type TokenChain, type TokenChainIconUrl, type TokenChainsResponse, type TokenMetadata, type UserIpInfo, type Wallet, createDepositAddress, createOnrampSession, getApiBaseUrl, getChainName, getDefaultOnrampToken, getFiatCurrencies, getIconUrl, getIconUrlWithCdn, getIpAddress, getOnrampQuotes, getOnrampSessionStartUrl, getPreferredIconUrl, getProjectConfig, getSupportedDepositTokens, getTokenChains, getTokenMetadata, getWalletByChainType, i18n, queryExecutions, setApiConfig, useUserIp };
|
package/dist/index.d.ts
CHANGED
|
@@ -22,7 +22,7 @@ declare function getIconUrl(iconPath: string): string;
|
|
|
22
22
|
declare function getIconUrlWithCdn(iconPath: string, assetCdnUrl?: string): string;
|
|
23
23
|
interface Wallet {
|
|
24
24
|
id: string;
|
|
25
|
-
chain_type: "ethereum" | "solana" | "bitcoin";
|
|
25
|
+
chain_type: "ethereum" | "solana" | "bitcoin" | "algorand";
|
|
26
26
|
address_type: string | null;
|
|
27
27
|
address: string;
|
|
28
28
|
destination_chain_type: string;
|
|
@@ -51,7 +51,7 @@ declare function createDepositAddress(overrides?: Partial<CreateDepositAddressRe
|
|
|
51
51
|
/**
|
|
52
52
|
* Get wallet address for a specific chain type
|
|
53
53
|
*/
|
|
54
|
-
declare function getWalletByChainType(wallets: Wallet[], chainType: "ethereum" | "solana" | "bitcoin"): Wallet | undefined;
|
|
54
|
+
declare function getWalletByChainType(wallets: Wallet[], chainType: "ethereum" | "solana" | "bitcoin" | "algorand"): Wallet | undefined;
|
|
55
55
|
interface AutoSwapRequest {
|
|
56
56
|
wallet_id: string;
|
|
57
57
|
origin_currency: string;
|
|
@@ -157,91 +157,169 @@ interface SupportedDepositTokensResponse {
|
|
|
157
157
|
* Get supported deposit tokens
|
|
158
158
|
* @param publishableKey - Optional publishable key, defaults to configured key
|
|
159
159
|
*/
|
|
160
|
-
declare function getSupportedDepositTokens(publishableKey?: string
|
|
161
|
-
|
|
160
|
+
declare function getSupportedDepositTokens(publishableKey?: string, options?: {
|
|
161
|
+
destination_token_address?: string;
|
|
162
|
+
destination_chain_id?: string;
|
|
163
|
+
destination_chain_type?: string;
|
|
164
|
+
}): Promise<SupportedDepositTokensResponse>;
|
|
165
|
+
interface TokenMetadata {
|
|
166
|
+
symbol: string;
|
|
167
|
+
name: string;
|
|
168
|
+
icon_url: string;
|
|
169
|
+
icon_urls: IconUrl[];
|
|
170
|
+
chain_name: string;
|
|
171
|
+
chain_type: string;
|
|
172
|
+
chain_id: string;
|
|
173
|
+
token_address: string;
|
|
174
|
+
decimals: number;
|
|
175
|
+
chain_icon_url: string;
|
|
176
|
+
chain_icon_urls: IconUrl[];
|
|
177
|
+
}
|
|
178
|
+
interface GetTokenMetadataRequest {
|
|
179
|
+
chain_type: string;
|
|
180
|
+
chain_id: string;
|
|
181
|
+
token_address: string;
|
|
182
|
+
}
|
|
183
|
+
/**
|
|
184
|
+
* Get token metadata for a specific token
|
|
185
|
+
* @param request - Token query parameters (chain_type, chain_id, token_address)
|
|
186
|
+
* @param publishableKey - Optional publishable key, defaults to configured key
|
|
187
|
+
*/
|
|
188
|
+
declare function getTokenMetadata(request: GetTokenMetadataRequest, publishableKey?: string): Promise<TokenMetadata | null>;
|
|
189
|
+
/**
|
|
190
|
+
* Get the preferred icon URL from an array of icon URLs
|
|
191
|
+
* @param iconUrls - Array of icon URLs with format information
|
|
192
|
+
* @param preferredFormat - Preferred format ("svg" or "png"), defaults to "svg"
|
|
193
|
+
* @returns The URL string for the preferred format, or first available if preferred not found
|
|
194
|
+
*/
|
|
195
|
+
declare function getPreferredIconUrl(iconUrls: IconUrl[] | undefined, preferredFormat?: "svg" | "png"): string | undefined;
|
|
196
|
+
interface FiatCurrency {
|
|
197
|
+
currency_code: string;
|
|
198
|
+
name: string;
|
|
199
|
+
icon_url: string;
|
|
200
|
+
icon_urls: IconUrl[];
|
|
201
|
+
country_codes: string[];
|
|
202
|
+
default_amount: number;
|
|
203
|
+
minimum_amount: number;
|
|
204
|
+
maximum_amount: number;
|
|
205
|
+
suggested_amounts: number[];
|
|
206
|
+
}
|
|
207
|
+
interface FiatCurrenciesResponse {
|
|
208
|
+
data: FiatCurrency[];
|
|
209
|
+
preferred: string[];
|
|
210
|
+
}
|
|
211
|
+
/**
|
|
212
|
+
* Get supported fiat currencies
|
|
213
|
+
* @param publishableKey - Optional publishable key, defaults to configured key
|
|
214
|
+
*/
|
|
215
|
+
declare function getFiatCurrencies(publishableKey?: string): Promise<FiatCurrenciesResponse>;
|
|
216
|
+
interface OnrampQuote {
|
|
162
217
|
transaction_type: string;
|
|
163
|
-
payment_method_type: string;
|
|
164
218
|
source_amount: number;
|
|
165
219
|
source_amount_without_fees: number;
|
|
166
220
|
fiat_amount_without_fees: number;
|
|
167
221
|
destination_amount_without_fees: number | null;
|
|
168
|
-
|
|
222
|
+
source_currency: string;
|
|
169
223
|
country_code: string;
|
|
170
224
|
total_fee: number;
|
|
171
225
|
network_fee: number;
|
|
172
226
|
transaction_fee: number;
|
|
173
227
|
destination_amount: number;
|
|
174
|
-
|
|
228
|
+
destination_currency: string;
|
|
229
|
+
destination_network: string;
|
|
175
230
|
exchange_rate: number;
|
|
231
|
+
payment_method_type: string;
|
|
176
232
|
customer_score: number;
|
|
177
233
|
service_provider: string;
|
|
178
234
|
service_provider_display_name: string;
|
|
235
|
+
icon_url: string;
|
|
236
|
+
icon_urls: IconUrl[];
|
|
179
237
|
institution_name: string | null;
|
|
180
|
-
low_kyc: boolean
|
|
238
|
+
low_kyc: boolean;
|
|
181
239
|
partner_fee: number | null;
|
|
182
|
-
icon_url: string;
|
|
183
240
|
}
|
|
184
|
-
interface
|
|
241
|
+
interface OnrampQuotesRequest {
|
|
185
242
|
country_code: string;
|
|
186
|
-
destination_currency_code: string;
|
|
187
243
|
source_amount: string;
|
|
188
|
-
|
|
244
|
+
source_currency: string;
|
|
245
|
+
destination_currency: string;
|
|
246
|
+
destination_network: string;
|
|
247
|
+
subdivision_code?: string;
|
|
189
248
|
}
|
|
190
|
-
interface
|
|
191
|
-
data:
|
|
249
|
+
interface OnrampQuotesResponse {
|
|
250
|
+
data: OnrampQuote[];
|
|
192
251
|
}
|
|
193
252
|
/**
|
|
194
|
-
* Get
|
|
195
|
-
* @param request -
|
|
253
|
+
* Get unified onramp quotes from all providers
|
|
254
|
+
* @param request - Onramp quotes request
|
|
196
255
|
* @param publishableKey - Optional publishable key, defaults to configured key
|
|
197
256
|
*/
|
|
198
|
-
declare function
|
|
199
|
-
interface
|
|
257
|
+
declare function getOnrampQuotes(request: OnrampQuotesRequest, publishableKey?: string): Promise<OnrampQuotesResponse>;
|
|
258
|
+
interface OnrampSessionRequest {
|
|
200
259
|
service_provider: string;
|
|
201
260
|
country_code: string;
|
|
202
|
-
|
|
203
|
-
source_currency_code: string;
|
|
204
|
-
wallet_address: string;
|
|
261
|
+
source_currency: string;
|
|
205
262
|
source_amount: string;
|
|
263
|
+
destination_currency: string;
|
|
264
|
+
destination_network: string;
|
|
265
|
+
wallet_address: string;
|
|
266
|
+
subdivision_code?: string;
|
|
267
|
+
redirect_url?: string;
|
|
206
268
|
}
|
|
207
|
-
interface
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
external_customer_id: string | null;
|
|
211
|
-
customer_id: string;
|
|
212
|
-
widget_url: string;
|
|
213
|
-
service_provider_widget_url: string;
|
|
214
|
-
token: string;
|
|
269
|
+
interface OnrampSessionResponse {
|
|
270
|
+
url: string;
|
|
271
|
+
service_provider: string;
|
|
215
272
|
}
|
|
216
273
|
/**
|
|
217
|
-
* Create a
|
|
218
|
-
* @param request -
|
|
274
|
+
* Create a unified onramp session
|
|
275
|
+
* @param request - Onramp session request
|
|
219
276
|
* @param publishableKey - Optional publishable key, defaults to configured key
|
|
220
277
|
*/
|
|
221
|
-
declare function
|
|
278
|
+
declare function createOnrampSession(request: OnrampSessionRequest, publishableKey?: string): Promise<OnrampSessionResponse>;
|
|
222
279
|
/**
|
|
223
|
-
*
|
|
224
|
-
*
|
|
225
|
-
* @param
|
|
226
|
-
* @
|
|
280
|
+
* Generate a URL for the sessions/start endpoint that redirects to the onramp provider.
|
|
281
|
+
* This is useful for avoiding popup blockers by opening the URL directly via anchor tag.
|
|
282
|
+
* @param request - Onramp session request (same parameters as createOnrampSession)
|
|
283
|
+
* @param publishableKey - Publishable key (required)
|
|
284
|
+
* @returns URL string that can be used in an anchor tag or window.open()
|
|
227
285
|
*/
|
|
228
|
-
declare function
|
|
229
|
-
interface
|
|
230
|
-
|
|
231
|
-
|
|
286
|
+
declare function getOnrampSessionStartUrl(request: OnrampSessionRequest, publishableKey: string): string;
|
|
287
|
+
interface DefaultTokenChain {
|
|
288
|
+
icon_url: string;
|
|
289
|
+
icon_urls: IconUrl[];
|
|
290
|
+
chain_id: string;
|
|
291
|
+
chain_name: string;
|
|
292
|
+
chain_type: string;
|
|
293
|
+
}
|
|
294
|
+
interface DefaultTokenMetadata {
|
|
232
295
|
icon_url: string;
|
|
233
|
-
icon_urls
|
|
234
|
-
|
|
296
|
+
icon_urls: IconUrl[];
|
|
297
|
+
decimals: number;
|
|
298
|
+
symbol: string;
|
|
299
|
+
name: string;
|
|
300
|
+
token_address: string;
|
|
301
|
+
chain_id: string;
|
|
302
|
+
chain_type: string;
|
|
303
|
+
chain_name: string;
|
|
304
|
+
chain: DefaultTokenChain;
|
|
235
305
|
}
|
|
236
|
-
interface
|
|
237
|
-
|
|
238
|
-
|
|
306
|
+
interface DefaultTokenResponse {
|
|
307
|
+
destination_network: string;
|
|
308
|
+
destination_currency: string;
|
|
309
|
+
destination_token_metadata: DefaultTokenMetadata;
|
|
239
310
|
}
|
|
240
311
|
/**
|
|
241
|
-
* Get
|
|
312
|
+
* Get default onramp token for a given token/chain combination
|
|
313
|
+
* @param params - Query parameters
|
|
242
314
|
* @param publishableKey - Optional publishable key, defaults to configured key
|
|
243
315
|
*/
|
|
244
|
-
declare function
|
|
316
|
+
declare function getDefaultOnrampToken(params: {
|
|
317
|
+
country_code?: string;
|
|
318
|
+
subdivision_code?: string;
|
|
319
|
+
token_address: string;
|
|
320
|
+
chain_id: string;
|
|
321
|
+
chain_type: string;
|
|
322
|
+
}, publishableKey?: string): Promise<DefaultTokenResponse>;
|
|
245
323
|
interface TokenChainIconUrl {
|
|
246
324
|
url: string;
|
|
247
325
|
format: string;
|
|
@@ -401,4 +479,4 @@ declare const i18n: {
|
|
|
401
479
|
};
|
|
402
480
|
type I18nStrings = typeof i18n;
|
|
403
481
|
|
|
404
|
-
export { type AutoSwapRequest, type AutoSwapResponse, type CreateDepositAddressRequest, type DepositAddressResponse, ExecutionStatus, type FeaturedToken, type FiatCurrenciesResponse, type FiatCurrency, type I18nStrings, type IconUrl, type IpAddressResponse, type
|
|
482
|
+
export { type AutoSwapRequest, type AutoSwapResponse, type CreateDepositAddressRequest, type DefaultTokenChain, type DefaultTokenMetadata, type DefaultTokenResponse, type DepositAddressResponse, ExecutionStatus, type FeaturedToken, type FiatCurrenciesResponse, type FiatCurrency, type I18nStrings, type IconUrl, type IpAddressResponse, type OnrampQuote, type OnrampQuotesRequest, type OnrampQuotesResponse, type OnrampSessionRequest, type OnrampSessionResponse, type PaymentNetwork, type ProjectConfigResponse, type QueryExecutionsRequest, type QueryExecutionsResponse, SOLANA_USDC_ADDRESS, type SupportedChain, type SupportedDepositTokensResponse, type SupportedToken, type TokenChain, type TokenChainIconUrl, type TokenChainsResponse, type TokenMetadata, type UserIpInfo, type Wallet, createDepositAddress, createOnrampSession, getApiBaseUrl, getChainName, getDefaultOnrampToken, getFiatCurrencies, getIconUrl, getIconUrlWithCdn, getIpAddress, getOnrampQuotes, getOnrampSessionStartUrl, getPreferredIconUrl, getProjectConfig, getSupportedDepositTokens, getTokenChains, getTokenMetadata, getWalletByChainType, i18n, queryExecutions, setApiConfig, useUserIp };
|
package/dist/index.js
CHANGED
|
@@ -23,18 +23,21 @@ __export(index_exports, {
|
|
|
23
23
|
ExecutionStatus: () => ExecutionStatus,
|
|
24
24
|
SOLANA_USDC_ADDRESS: () => SOLANA_USDC_ADDRESS,
|
|
25
25
|
createDepositAddress: () => createDepositAddress,
|
|
26
|
-
|
|
26
|
+
createOnrampSession: () => createOnrampSession,
|
|
27
27
|
getApiBaseUrl: () => getApiBaseUrl,
|
|
28
28
|
getChainName: () => getChainName,
|
|
29
|
+
getDefaultOnrampToken: () => getDefaultOnrampToken,
|
|
29
30
|
getFiatCurrencies: () => getFiatCurrencies,
|
|
30
31
|
getIconUrl: () => getIconUrl,
|
|
31
32
|
getIconUrlWithCdn: () => getIconUrlWithCdn,
|
|
32
33
|
getIpAddress: () => getIpAddress,
|
|
33
|
-
|
|
34
|
+
getOnrampQuotes: () => getOnrampQuotes,
|
|
35
|
+
getOnrampSessionStartUrl: () => getOnrampSessionStartUrl,
|
|
34
36
|
getPreferredIconUrl: () => getPreferredIconUrl,
|
|
35
37
|
getProjectConfig: () => getProjectConfig,
|
|
36
38
|
getSupportedDepositTokens: () => getSupportedDepositTokens,
|
|
37
39
|
getTokenChains: () => getTokenChains,
|
|
40
|
+
getTokenMetadata: () => getTokenMetadata,
|
|
38
41
|
getWalletByChainType: () => getWalletByChainType,
|
|
39
42
|
i18n: () => i18n,
|
|
40
43
|
queryExecutions: () => queryExecutions,
|
|
@@ -158,11 +161,42 @@ async function queryExecutions(externalUserId, publishableKey) {
|
|
|
158
161
|
}
|
|
159
162
|
return response.json();
|
|
160
163
|
}
|
|
161
|
-
async function getSupportedDepositTokens(publishableKey) {
|
|
164
|
+
async function getSupportedDepositTokens(publishableKey, options) {
|
|
162
165
|
const pk = publishableKey || DEFAULT_PUBLISHABLE_KEY;
|
|
163
166
|
validatePublishableKey(pk);
|
|
167
|
+
let url = `${API_BASE_URL}/v1/public/tokens/supported_deposit_tokens`;
|
|
168
|
+
if (options?.destination_token_address && options?.destination_chain_id && options?.destination_chain_type) {
|
|
169
|
+
const params = new URLSearchParams({
|
|
170
|
+
destination_token_address: options.destination_token_address,
|
|
171
|
+
destination_chain_id: options.destination_chain_id,
|
|
172
|
+
destination_chain_type: options.destination_chain_type
|
|
173
|
+
});
|
|
174
|
+
url = `${url}?${params.toString()}`;
|
|
175
|
+
}
|
|
176
|
+
const response = await fetch(url, {
|
|
177
|
+
method: "GET",
|
|
178
|
+
headers: {
|
|
179
|
+
accept: "application/json",
|
|
180
|
+
"x-publishable-key": pk
|
|
181
|
+
}
|
|
182
|
+
});
|
|
183
|
+
if (!response.ok) {
|
|
184
|
+
throw new Error(
|
|
185
|
+
`Failed to fetch supported deposit tokens: ${response.statusText}`
|
|
186
|
+
);
|
|
187
|
+
}
|
|
188
|
+
return response.json();
|
|
189
|
+
}
|
|
190
|
+
async function getTokenMetadata(request, publishableKey) {
|
|
191
|
+
const pk = publishableKey || DEFAULT_PUBLISHABLE_KEY;
|
|
192
|
+
validatePublishableKey(pk);
|
|
193
|
+
const params = new URLSearchParams({
|
|
194
|
+
chainType: request.chain_type,
|
|
195
|
+
chainId: request.chain_id,
|
|
196
|
+
tokenAddress: request.token_address
|
|
197
|
+
});
|
|
164
198
|
const response = await fetch(
|
|
165
|
-
`${API_BASE_URL}/v1/public/tokens/
|
|
199
|
+
`${API_BASE_URL}/v1/public/tokens/token?${params.toString()}`,
|
|
166
200
|
{
|
|
167
201
|
method: "GET",
|
|
168
202
|
headers: {
|
|
@@ -172,17 +206,43 @@ async function getSupportedDepositTokens(publishableKey) {
|
|
|
172
206
|
}
|
|
173
207
|
);
|
|
174
208
|
if (!response.ok) {
|
|
175
|
-
throw new Error(
|
|
176
|
-
|
|
177
|
-
|
|
209
|
+
throw new Error(`Failed to fetch token metadata: ${response.statusText}`);
|
|
210
|
+
}
|
|
211
|
+
return response.json();
|
|
212
|
+
}
|
|
213
|
+
function getPreferredIconUrl(iconUrls, preferredFormat = "svg") {
|
|
214
|
+
if (!iconUrls || iconUrls.length === 0) {
|
|
215
|
+
return void 0;
|
|
216
|
+
}
|
|
217
|
+
const preferred = iconUrls.find((icon) => icon.format === preferredFormat);
|
|
218
|
+
if (preferred) {
|
|
219
|
+
return preferred.url;
|
|
220
|
+
}
|
|
221
|
+
return iconUrls[0]?.url;
|
|
222
|
+
}
|
|
223
|
+
async function getFiatCurrencies(publishableKey) {
|
|
224
|
+
const pk = publishableKey || DEFAULT_PUBLISHABLE_KEY;
|
|
225
|
+
validatePublishableKey(pk);
|
|
226
|
+
const response = await fetch(
|
|
227
|
+
`${API_BASE_URL}/v1/public/onramps/fiat_currencies`,
|
|
228
|
+
{
|
|
229
|
+
method: "GET",
|
|
230
|
+
headers: {
|
|
231
|
+
accept: "application/json",
|
|
232
|
+
"x-publishable-key": pk
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
);
|
|
236
|
+
if (!response.ok) {
|
|
237
|
+
throw new Error(`Failed to fetch fiat currencies: ${response.statusText}`);
|
|
178
238
|
}
|
|
179
239
|
return response.json();
|
|
180
240
|
}
|
|
181
|
-
async function
|
|
241
|
+
async function getOnrampQuotes(request, publishableKey) {
|
|
182
242
|
const pk = publishableKey || DEFAULT_PUBLISHABLE_KEY;
|
|
183
243
|
validatePublishableKey(pk);
|
|
184
244
|
const response = await fetch(
|
|
185
|
-
`${API_BASE_URL}/v1/public/onramps/
|
|
245
|
+
`${API_BASE_URL}/v1/public/onramps/quotes`,
|
|
186
246
|
{
|
|
187
247
|
method: "POST",
|
|
188
248
|
headers: {
|
|
@@ -194,15 +254,15 @@ async function getMeldQuotes(request, publishableKey) {
|
|
|
194
254
|
}
|
|
195
255
|
);
|
|
196
256
|
if (!response.ok) {
|
|
197
|
-
throw new Error(`Failed to fetch
|
|
257
|
+
throw new Error(`Failed to fetch onramp quotes: ${response.statusText}`);
|
|
198
258
|
}
|
|
199
259
|
return response.json();
|
|
200
260
|
}
|
|
201
|
-
async function
|
|
261
|
+
async function createOnrampSession(request, publishableKey) {
|
|
202
262
|
const pk = publishableKey || DEFAULT_PUBLISHABLE_KEY;
|
|
203
263
|
validatePublishableKey(pk);
|
|
204
264
|
const response = await fetch(
|
|
205
|
-
`${API_BASE_URL}/v1/public/onramps/
|
|
265
|
+
`${API_BASE_URL}/v1/public/onramps/sessions`,
|
|
206
266
|
{
|
|
207
267
|
method: "POST",
|
|
208
268
|
headers: {
|
|
@@ -214,25 +274,36 @@ async function createMeldSession(request, publishableKey) {
|
|
|
214
274
|
}
|
|
215
275
|
);
|
|
216
276
|
if (!response.ok) {
|
|
217
|
-
throw new Error(`Failed to create
|
|
277
|
+
throw new Error(`Failed to create onramp session: ${response.statusText}`);
|
|
218
278
|
}
|
|
219
279
|
return response.json();
|
|
220
280
|
}
|
|
221
|
-
function
|
|
222
|
-
|
|
223
|
-
|
|
281
|
+
function getOnrampSessionStartUrl(request, publishableKey) {
|
|
282
|
+
const params = new URLSearchParams();
|
|
283
|
+
params.append("publishable_key", publishableKey);
|
|
284
|
+
params.append("service_provider", request.service_provider);
|
|
285
|
+
params.append("country_code", request.country_code);
|
|
286
|
+
params.append("source_currency", request.source_currency);
|
|
287
|
+
params.append("source_amount", request.source_amount);
|
|
288
|
+
params.append("destination_currency", request.destination_currency);
|
|
289
|
+
params.append("destination_network", request.destination_network);
|
|
290
|
+
params.append("wallet_address", request.wallet_address);
|
|
291
|
+
if (request.subdivision_code) {
|
|
292
|
+
params.append("subdivision_code", request.subdivision_code);
|
|
224
293
|
}
|
|
225
|
-
|
|
226
|
-
if (preferred) {
|
|
227
|
-
return preferred.url;
|
|
228
|
-
}
|
|
229
|
-
return iconUrls[0]?.url;
|
|
294
|
+
return `${API_BASE_URL}/v1/public/onramps/sessions/start?${params.toString()}`;
|
|
230
295
|
}
|
|
231
|
-
async function
|
|
296
|
+
async function getDefaultOnrampToken(params, publishableKey) {
|
|
232
297
|
const pk = publishableKey || DEFAULT_PUBLISHABLE_KEY;
|
|
233
298
|
validatePublishableKey(pk);
|
|
299
|
+
const queryParams = new URLSearchParams();
|
|
300
|
+
if (params.country_code) queryParams.append("country_code", params.country_code);
|
|
301
|
+
if (params.subdivision_code) queryParams.append("subdivision_code", params.subdivision_code);
|
|
302
|
+
queryParams.append("token_address", params.token_address);
|
|
303
|
+
queryParams.append("chain_id", params.chain_id);
|
|
304
|
+
queryParams.append("chain_type", params.chain_type);
|
|
234
305
|
const response = await fetch(
|
|
235
|
-
`${API_BASE_URL}/v1/public/onramps/
|
|
306
|
+
`${API_BASE_URL}/v1/public/onramps/default_token?${queryParams.toString()}`,
|
|
236
307
|
{
|
|
237
308
|
method: "GET",
|
|
238
309
|
headers: {
|
|
@@ -242,7 +313,7 @@ async function getFiatCurrencies(publishableKey) {
|
|
|
242
313
|
}
|
|
243
314
|
);
|
|
244
315
|
if (!response.ok) {
|
|
245
|
-
throw new Error(`Failed to fetch
|
|
316
|
+
throw new Error(`Failed to fetch default onramp token: ${response.statusText}`);
|
|
246
317
|
}
|
|
247
318
|
return response.json();
|
|
248
319
|
}
|
|
@@ -259,6 +330,8 @@ async function getTokenChains() {
|
|
|
259
330
|
return response.json();
|
|
260
331
|
}
|
|
261
332
|
function getChainName(chains, chainType, chainId) {
|
|
333
|
+
const target = chains.find((c) => c.chain_id === chainId && c.chain_type === chainType);
|
|
334
|
+
if (target) return target.chain_name;
|
|
262
335
|
const byId = chains.find((c) => c.chain_id === chainId);
|
|
263
336
|
if (byId) return byId.chain_name;
|
|
264
337
|
const byType = chains.find((c) => c.chain_type === chainType);
|
|
@@ -405,18 +478,21 @@ var i18n = en_default;
|
|
|
405
478
|
ExecutionStatus,
|
|
406
479
|
SOLANA_USDC_ADDRESS,
|
|
407
480
|
createDepositAddress,
|
|
408
|
-
|
|
481
|
+
createOnrampSession,
|
|
409
482
|
getApiBaseUrl,
|
|
410
483
|
getChainName,
|
|
484
|
+
getDefaultOnrampToken,
|
|
411
485
|
getFiatCurrencies,
|
|
412
486
|
getIconUrl,
|
|
413
487
|
getIconUrlWithCdn,
|
|
414
488
|
getIpAddress,
|
|
415
|
-
|
|
489
|
+
getOnrampQuotes,
|
|
490
|
+
getOnrampSessionStartUrl,
|
|
416
491
|
getPreferredIconUrl,
|
|
417
492
|
getProjectConfig,
|
|
418
493
|
getSupportedDepositTokens,
|
|
419
494
|
getTokenChains,
|
|
495
|
+
getTokenMetadata,
|
|
420
496
|
getWalletByChainType,
|
|
421
497
|
i18n,
|
|
422
498
|
queryExecutions,
|
package/dist/index.mjs
CHANGED
|
@@ -113,11 +113,42 @@ async function queryExecutions(externalUserId, publishableKey) {
|
|
|
113
113
|
}
|
|
114
114
|
return response.json();
|
|
115
115
|
}
|
|
116
|
-
async function getSupportedDepositTokens(publishableKey) {
|
|
116
|
+
async function getSupportedDepositTokens(publishableKey, options) {
|
|
117
117
|
const pk = publishableKey || DEFAULT_PUBLISHABLE_KEY;
|
|
118
118
|
validatePublishableKey(pk);
|
|
119
|
+
let url = `${API_BASE_URL}/v1/public/tokens/supported_deposit_tokens`;
|
|
120
|
+
if (options?.destination_token_address && options?.destination_chain_id && options?.destination_chain_type) {
|
|
121
|
+
const params = new URLSearchParams({
|
|
122
|
+
destination_token_address: options.destination_token_address,
|
|
123
|
+
destination_chain_id: options.destination_chain_id,
|
|
124
|
+
destination_chain_type: options.destination_chain_type
|
|
125
|
+
});
|
|
126
|
+
url = `${url}?${params.toString()}`;
|
|
127
|
+
}
|
|
128
|
+
const response = await fetch(url, {
|
|
129
|
+
method: "GET",
|
|
130
|
+
headers: {
|
|
131
|
+
accept: "application/json",
|
|
132
|
+
"x-publishable-key": pk
|
|
133
|
+
}
|
|
134
|
+
});
|
|
135
|
+
if (!response.ok) {
|
|
136
|
+
throw new Error(
|
|
137
|
+
`Failed to fetch supported deposit tokens: ${response.statusText}`
|
|
138
|
+
);
|
|
139
|
+
}
|
|
140
|
+
return response.json();
|
|
141
|
+
}
|
|
142
|
+
async function getTokenMetadata(request, publishableKey) {
|
|
143
|
+
const pk = publishableKey || DEFAULT_PUBLISHABLE_KEY;
|
|
144
|
+
validatePublishableKey(pk);
|
|
145
|
+
const params = new URLSearchParams({
|
|
146
|
+
chainType: request.chain_type,
|
|
147
|
+
chainId: request.chain_id,
|
|
148
|
+
tokenAddress: request.token_address
|
|
149
|
+
});
|
|
119
150
|
const response = await fetch(
|
|
120
|
-
`${API_BASE_URL}/v1/public/tokens/
|
|
151
|
+
`${API_BASE_URL}/v1/public/tokens/token?${params.toString()}`,
|
|
121
152
|
{
|
|
122
153
|
method: "GET",
|
|
123
154
|
headers: {
|
|
@@ -127,17 +158,43 @@ async function getSupportedDepositTokens(publishableKey) {
|
|
|
127
158
|
}
|
|
128
159
|
);
|
|
129
160
|
if (!response.ok) {
|
|
130
|
-
throw new Error(
|
|
131
|
-
|
|
132
|
-
|
|
161
|
+
throw new Error(`Failed to fetch token metadata: ${response.statusText}`);
|
|
162
|
+
}
|
|
163
|
+
return response.json();
|
|
164
|
+
}
|
|
165
|
+
function getPreferredIconUrl(iconUrls, preferredFormat = "svg") {
|
|
166
|
+
if (!iconUrls || iconUrls.length === 0) {
|
|
167
|
+
return void 0;
|
|
168
|
+
}
|
|
169
|
+
const preferred = iconUrls.find((icon) => icon.format === preferredFormat);
|
|
170
|
+
if (preferred) {
|
|
171
|
+
return preferred.url;
|
|
172
|
+
}
|
|
173
|
+
return iconUrls[0]?.url;
|
|
174
|
+
}
|
|
175
|
+
async function getFiatCurrencies(publishableKey) {
|
|
176
|
+
const pk = publishableKey || DEFAULT_PUBLISHABLE_KEY;
|
|
177
|
+
validatePublishableKey(pk);
|
|
178
|
+
const response = await fetch(
|
|
179
|
+
`${API_BASE_URL}/v1/public/onramps/fiat_currencies`,
|
|
180
|
+
{
|
|
181
|
+
method: "GET",
|
|
182
|
+
headers: {
|
|
183
|
+
accept: "application/json",
|
|
184
|
+
"x-publishable-key": pk
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
);
|
|
188
|
+
if (!response.ok) {
|
|
189
|
+
throw new Error(`Failed to fetch fiat currencies: ${response.statusText}`);
|
|
133
190
|
}
|
|
134
191
|
return response.json();
|
|
135
192
|
}
|
|
136
|
-
async function
|
|
193
|
+
async function getOnrampQuotes(request, publishableKey) {
|
|
137
194
|
const pk = publishableKey || DEFAULT_PUBLISHABLE_KEY;
|
|
138
195
|
validatePublishableKey(pk);
|
|
139
196
|
const response = await fetch(
|
|
140
|
-
`${API_BASE_URL}/v1/public/onramps/
|
|
197
|
+
`${API_BASE_URL}/v1/public/onramps/quotes`,
|
|
141
198
|
{
|
|
142
199
|
method: "POST",
|
|
143
200
|
headers: {
|
|
@@ -149,15 +206,15 @@ async function getMeldQuotes(request, publishableKey) {
|
|
|
149
206
|
}
|
|
150
207
|
);
|
|
151
208
|
if (!response.ok) {
|
|
152
|
-
throw new Error(`Failed to fetch
|
|
209
|
+
throw new Error(`Failed to fetch onramp quotes: ${response.statusText}`);
|
|
153
210
|
}
|
|
154
211
|
return response.json();
|
|
155
212
|
}
|
|
156
|
-
async function
|
|
213
|
+
async function createOnrampSession(request, publishableKey) {
|
|
157
214
|
const pk = publishableKey || DEFAULT_PUBLISHABLE_KEY;
|
|
158
215
|
validatePublishableKey(pk);
|
|
159
216
|
const response = await fetch(
|
|
160
|
-
`${API_BASE_URL}/v1/public/onramps/
|
|
217
|
+
`${API_BASE_URL}/v1/public/onramps/sessions`,
|
|
161
218
|
{
|
|
162
219
|
method: "POST",
|
|
163
220
|
headers: {
|
|
@@ -169,25 +226,36 @@ async function createMeldSession(request, publishableKey) {
|
|
|
169
226
|
}
|
|
170
227
|
);
|
|
171
228
|
if (!response.ok) {
|
|
172
|
-
throw new Error(`Failed to create
|
|
229
|
+
throw new Error(`Failed to create onramp session: ${response.statusText}`);
|
|
173
230
|
}
|
|
174
231
|
return response.json();
|
|
175
232
|
}
|
|
176
|
-
function
|
|
177
|
-
|
|
178
|
-
|
|
233
|
+
function getOnrampSessionStartUrl(request, publishableKey) {
|
|
234
|
+
const params = new URLSearchParams();
|
|
235
|
+
params.append("publishable_key", publishableKey);
|
|
236
|
+
params.append("service_provider", request.service_provider);
|
|
237
|
+
params.append("country_code", request.country_code);
|
|
238
|
+
params.append("source_currency", request.source_currency);
|
|
239
|
+
params.append("source_amount", request.source_amount);
|
|
240
|
+
params.append("destination_currency", request.destination_currency);
|
|
241
|
+
params.append("destination_network", request.destination_network);
|
|
242
|
+
params.append("wallet_address", request.wallet_address);
|
|
243
|
+
if (request.subdivision_code) {
|
|
244
|
+
params.append("subdivision_code", request.subdivision_code);
|
|
179
245
|
}
|
|
180
|
-
|
|
181
|
-
if (preferred) {
|
|
182
|
-
return preferred.url;
|
|
183
|
-
}
|
|
184
|
-
return iconUrls[0]?.url;
|
|
246
|
+
return `${API_BASE_URL}/v1/public/onramps/sessions/start?${params.toString()}`;
|
|
185
247
|
}
|
|
186
|
-
async function
|
|
248
|
+
async function getDefaultOnrampToken(params, publishableKey) {
|
|
187
249
|
const pk = publishableKey || DEFAULT_PUBLISHABLE_KEY;
|
|
188
250
|
validatePublishableKey(pk);
|
|
251
|
+
const queryParams = new URLSearchParams();
|
|
252
|
+
if (params.country_code) queryParams.append("country_code", params.country_code);
|
|
253
|
+
if (params.subdivision_code) queryParams.append("subdivision_code", params.subdivision_code);
|
|
254
|
+
queryParams.append("token_address", params.token_address);
|
|
255
|
+
queryParams.append("chain_id", params.chain_id);
|
|
256
|
+
queryParams.append("chain_type", params.chain_type);
|
|
189
257
|
const response = await fetch(
|
|
190
|
-
`${API_BASE_URL}/v1/public/onramps/
|
|
258
|
+
`${API_BASE_URL}/v1/public/onramps/default_token?${queryParams.toString()}`,
|
|
191
259
|
{
|
|
192
260
|
method: "GET",
|
|
193
261
|
headers: {
|
|
@@ -197,7 +265,7 @@ async function getFiatCurrencies(publishableKey) {
|
|
|
197
265
|
}
|
|
198
266
|
);
|
|
199
267
|
if (!response.ok) {
|
|
200
|
-
throw new Error(`Failed to fetch
|
|
268
|
+
throw new Error(`Failed to fetch default onramp token: ${response.statusText}`);
|
|
201
269
|
}
|
|
202
270
|
return response.json();
|
|
203
271
|
}
|
|
@@ -214,6 +282,8 @@ async function getTokenChains() {
|
|
|
214
282
|
return response.json();
|
|
215
283
|
}
|
|
216
284
|
function getChainName(chains, chainType, chainId) {
|
|
285
|
+
const target = chains.find((c) => c.chain_id === chainId && c.chain_type === chainType);
|
|
286
|
+
if (target) return target.chain_name;
|
|
217
287
|
const byId = chains.find((c) => c.chain_id === chainId);
|
|
218
288
|
if (byId) return byId.chain_name;
|
|
219
289
|
const byType = chains.find((c) => c.chain_type === chainType);
|
|
@@ -359,18 +429,21 @@ export {
|
|
|
359
429
|
ExecutionStatus,
|
|
360
430
|
SOLANA_USDC_ADDRESS,
|
|
361
431
|
createDepositAddress,
|
|
362
|
-
|
|
432
|
+
createOnrampSession,
|
|
363
433
|
getApiBaseUrl,
|
|
364
434
|
getChainName,
|
|
435
|
+
getDefaultOnrampToken,
|
|
365
436
|
getFiatCurrencies,
|
|
366
437
|
getIconUrl,
|
|
367
438
|
getIconUrlWithCdn,
|
|
368
439
|
getIpAddress,
|
|
369
|
-
|
|
440
|
+
getOnrampQuotes,
|
|
441
|
+
getOnrampSessionStartUrl,
|
|
370
442
|
getPreferredIconUrl,
|
|
371
443
|
getProjectConfig,
|
|
372
444
|
getSupportedDepositTokens,
|
|
373
445
|
getTokenChains,
|
|
446
|
+
getTokenMetadata,
|
|
374
447
|
getWalletByChainType,
|
|
375
448
|
i18n,
|
|
376
449
|
queryExecutions,
|