@unifold/core 0.1.53 → 0.1.55
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 +69 -3
- package/dist/index.d.ts +69 -3
- package/dist/index.js +98 -13
- package/dist/index.mjs +94 -13
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -76,6 +76,7 @@ interface IconUrl {
|
|
|
76
76
|
url: string;
|
|
77
77
|
format: "svg" | "png";
|
|
78
78
|
}
|
|
79
|
+
type ProductType = "deposit" | "payment";
|
|
79
80
|
interface AutoSwapResponse {
|
|
80
81
|
id: string;
|
|
81
82
|
project_id: string;
|
|
@@ -157,6 +158,7 @@ interface SupportedChain {
|
|
|
157
158
|
chain_type: string;
|
|
158
159
|
icon_url: string;
|
|
159
160
|
token_address: string;
|
|
161
|
+
decimals: number;
|
|
160
162
|
estimated_price_impact_percent: number;
|
|
161
163
|
max_slippage_percent: number;
|
|
162
164
|
estimated_processing_time: number | null;
|
|
@@ -184,13 +186,17 @@ interface SupportedDestinationTokensResponse {
|
|
|
184
186
|
/**
|
|
185
187
|
* Get supported destination tokens (used for withdraw flow)
|
|
186
188
|
* @param publishableKey - Optional publishable key, defaults to configured key
|
|
189
|
+
* @param options - Optional query parameters
|
|
187
190
|
*/
|
|
188
|
-
declare function getSupportedDestinationTokens(publishableKey?: string
|
|
191
|
+
declare function getSupportedDestinationTokens(publishableKey?: string, options?: {
|
|
192
|
+
product_type?: ProductType;
|
|
193
|
+
}): Promise<SupportedDestinationTokensResponse>;
|
|
189
194
|
interface SupportedToken {
|
|
190
195
|
symbol: string;
|
|
191
196
|
name: string;
|
|
192
197
|
icon_url: string;
|
|
193
198
|
is_newly_added: boolean;
|
|
199
|
+
is_stablecoin: boolean;
|
|
194
200
|
chains: SupportedChain[];
|
|
195
201
|
}
|
|
196
202
|
interface SupportedDepositTokensResponse {
|
|
@@ -204,7 +210,7 @@ declare function getSupportedDepositTokens(publishableKey?: string, options?: {
|
|
|
204
210
|
destination_token_address?: string;
|
|
205
211
|
destination_chain_id?: string;
|
|
206
212
|
destination_chain_type?: string;
|
|
207
|
-
product_type?:
|
|
213
|
+
product_type?: ProductType;
|
|
208
214
|
}): Promise<SupportedDepositTokensResponse>;
|
|
209
215
|
interface TokenMetadata {
|
|
210
216
|
symbol: string;
|
|
@@ -407,12 +413,20 @@ interface BlockedCountrySubdivision {
|
|
|
407
413
|
country_code: string;
|
|
408
414
|
subdivision_codes: string[];
|
|
409
415
|
}
|
|
416
|
+
interface FeaturedWallet {
|
|
417
|
+
name: string;
|
|
418
|
+
position: number;
|
|
419
|
+
icon_urls: IconUrl[];
|
|
420
|
+
}
|
|
410
421
|
interface ProjectConfigResponse {
|
|
411
422
|
project_name?: string;
|
|
412
423
|
asset_cdn_url: string;
|
|
413
424
|
transfer_crypto: {
|
|
414
425
|
networks: FeaturedToken[];
|
|
415
426
|
};
|
|
427
|
+
connect_wallet: {
|
|
428
|
+
wallets: FeaturedWallet[];
|
|
429
|
+
};
|
|
416
430
|
payment_networks: {
|
|
417
431
|
networks: PaymentNetwork[];
|
|
418
432
|
};
|
|
@@ -753,6 +767,8 @@ interface PaymentIntent {
|
|
|
753
767
|
description: string | null;
|
|
754
768
|
livemode: boolean;
|
|
755
769
|
settlement_tolerance_percent: number;
|
|
770
|
+
/** When true, stablecoin deposits are credited at par (1:1) regardless of swap slippage. */
|
|
771
|
+
stablecoin_parity: boolean;
|
|
756
772
|
canceled_at: string | null;
|
|
757
773
|
cancellation_reason: string | null;
|
|
758
774
|
expires_at: string | null;
|
|
@@ -888,6 +904,11 @@ interface DepositQuoteRequest {
|
|
|
888
904
|
* reduce stuck payments. Typically set by the checkout flow.
|
|
889
905
|
*/
|
|
890
906
|
adjust_for_slippage?: boolean;
|
|
907
|
+
/**
|
|
908
|
+
* When true and both tokens are stablecoins, returns a 1:1 quote
|
|
909
|
+
* without calling the swap provider. Ignored if source is not a stablecoin.
|
|
910
|
+
*/
|
|
911
|
+
stablecoin_parity?: boolean;
|
|
891
912
|
}
|
|
892
913
|
interface DepositQuote {
|
|
893
914
|
/**
|
|
@@ -959,8 +980,53 @@ declare function buildHypercoreTransaction(request: BuildHypercoreTransactionReq
|
|
|
959
980
|
* Pass the action + nonce from buildHypercoreTransaction and
|
|
960
981
|
* the signature from eth_signTypedData_v4.
|
|
961
982
|
*/
|
|
983
|
+
interface CashAppSessionRequest {
|
|
984
|
+
external_user_id: string;
|
|
985
|
+
destination_chain_type: string;
|
|
986
|
+
destination_chain_id: string;
|
|
987
|
+
destination_token_address: string;
|
|
988
|
+
recipient_address: string;
|
|
989
|
+
source_amount: string;
|
|
990
|
+
external_id?: string;
|
|
991
|
+
}
|
|
992
|
+
interface CashAppSessionResponse {
|
|
993
|
+
id: string;
|
|
994
|
+
external_id: string;
|
|
995
|
+
url: string;
|
|
996
|
+
status: string;
|
|
997
|
+
destination_amount: string;
|
|
998
|
+
expires_at: string;
|
|
999
|
+
}
|
|
1000
|
+
interface CashAppSessionStatusResponse {
|
|
1001
|
+
status: string;
|
|
1002
|
+
updated_at?: string;
|
|
1003
|
+
}
|
|
1004
|
+
interface CashAppLimits {
|
|
1005
|
+
minimum_amount: number;
|
|
1006
|
+
maximum_amount: number | null;
|
|
1007
|
+
currency: string;
|
|
1008
|
+
}
|
|
1009
|
+
declare function getCashAppLimits(currency?: string, publishableKey?: string): Promise<CashAppLimits>;
|
|
1010
|
+
declare function createCashAppSession(request: CashAppSessionRequest, publishableKey?: string): Promise<CashAppSessionResponse>;
|
|
1011
|
+
declare function getCashAppSessionStatus(externalId: string, publishableKey?: string): Promise<CashAppSessionStatusResponse>;
|
|
962
1012
|
declare function sendHypercoreTransaction(request: SendHypercoreTransactionRequest, publishableKey?: string): Promise<SendHypercoreTransactionResponse>;
|
|
963
1013
|
|
|
1014
|
+
/**
|
|
1015
|
+
* Format a stablecoin amount to 2 decimal places, ceiling any fractional
|
|
1016
|
+
* value beyond the 2nd decimal. This ensures the displayed amount is always
|
|
1017
|
+
* >= the real amount, so the user never underpays.
|
|
1018
|
+
*
|
|
1019
|
+
* @param baseUnits - Amount in base units (e.g. "5123456")
|
|
1020
|
+
* @param decimals - Token decimals (e.g. 6 for USDC)
|
|
1021
|
+
* @returns Formatted string with exactly 2 decimal places (e.g. "5.13")
|
|
1022
|
+
*
|
|
1023
|
+
* @example
|
|
1024
|
+
* formatStablecoinAmount("5123456", 6) // "5.13" (5.123456 → ceil)
|
|
1025
|
+
* formatStablecoinAmount("5120000", 6) // "5.12" (exact, no rounding)
|
|
1026
|
+
* formatStablecoinAmount("3450050", 6) // "3.46" (3.450050 → ceil)
|
|
1027
|
+
* formatStablecoinAmount("10000000", 6) // "10.00" (whole number)
|
|
1028
|
+
*/
|
|
1029
|
+
declare function formatStablecoinAmount(baseUnits: string, decimals: number): string;
|
|
964
1030
|
/**
|
|
965
1031
|
* Generate a KSUID-like prefixed ID without external dependencies.
|
|
966
1032
|
* Format: `{prefix}_{base62(4-byte-timestamp + 16-random-bytes)}` (27 chars after prefix).
|
|
@@ -1123,4 +1189,4 @@ declare const i18n: {
|
|
|
1123
1189
|
};
|
|
1124
1190
|
type I18nStrings = typeof i18n;
|
|
1125
1191
|
|
|
1126
|
-
export { ActionType, type AddressBalanceResponse, type AddressBalancesResponse, type AddressValidationFailureCode, type AddressValidationMetadata, type AutoSwapRequest, type AutoSwapResponse, type BlockedCountrySubdivision, type BuildHypercoreTransactionRequest, type BuildHypercoreTransactionResponse, type BuildSolanaTransactionRequest, type BuildSolanaTransactionResponse, type ChainType, type CreateDepositAddressRequest, type CreateExchangeSessionRequest, type CreateExchangeSessionResponse, type DefaultTokenChain, type DefaultTokenMetadata, type DefaultTokenResponse, type DepositAddressResponse, type DepositEvent, DepositEventType, type DepositQuote, type DepositQuoteRequest, type DestinationToken, type DestinationTokenChain, type ExchangeProviderInfo, type ExchangeProvidersResponse, type ExchangeSessionStartParams, type ExchangeWalletAddress, ExecutionStatus, type FeaturedToken, type FiatCurrenciesResponse, type FiatCurrency, type GetExchangesQuery, type HypercoreActionType, type HypercoreActivationRequest, type HypercoreActivationResponse, type I18nStrings, type IconUrl, IneligibilityReason, type IpAddressResponse, type LockedQuoteLimits, type LockedQuotePreview, type LockedQuotePreviewRequest, type OnrampQuote, type OnrampQuotesRequest, type OnrampQuotesResponse, type OnrampSessionCreatedData, type OnrampSessionCreatedEvent, type OnrampSessionRequest, type OnrampSessionResponse, type PaymentIntent, type PaymentIntentDepositAddress, type PaymentIntentExecutionsResponse, type PaymentIntentStatus, type PaymentIntentType, type PaymentNetwork, type PollExecutionsRequest, type PollExecutionsResponse, type ProjectConfigResponse, type QueryExecutionsRequest, type QueryExecutionsResponse, SOLANA_USDC_ADDRESS, type SendHypercoreTransactionRequest, type SendHypercoreTransactionResponse, type SendSolanaTransactionRequest, type SendSolanaTransactionResponse, type SourceToken, type SourceTokenNetwork, type SupportedChain, type SupportedDepositTokensResponse, type SupportedDestinationTokensResponse, type SupportedSourceTokensQuery, type SupportedSourceTokensResponse, type SupportedToken, type TokenBalance, type TokenChain, type TokenChainIconUrl, type TokenChainsResponse, type TokenIconUrl, type TokenInfo, type TokenMetadata, type UserIpInfo, type VerifyAddressRequest, type VerifyAddressResponse, type Wallet, buildHypercoreTransaction, buildSolanaTransaction, checkHypercoreActivation, createDepositAddress, createExchangeSession, createOnrampSession, generatePrefixedKSUID, getAddressBalance, getAddressBalances, getApiBaseUrl, getChainName, getDefaultOnrampToken, getDepositQuote, getExchangeSessionStartUrl, getExchanges, getFiatCurrencies, getIconUrl, getIconUrlWithCdn, getIpAddress, getOnrampQuotes, getOnrampSessionStartUrl, getPreferredIconUrl, getProjectConfig, getSupportedDepositTokens, getSupportedDestinationTokens, getTokenChains, getTokenMetadata, getWalletByChainType, i18n, listPaymentIntentExecutions, pollDirectExecutions, queryExecutions, retrievePaymentIntent, sendHypercoreTransaction, sendSolanaTransaction, setApiConfig, useUserIp, verifyRecipientAddress };
|
|
1192
|
+
export { ActionType, type AddressBalanceResponse, type AddressBalancesResponse, type AddressValidationFailureCode, type AddressValidationMetadata, type AutoSwapRequest, type AutoSwapResponse, type BlockedCountrySubdivision, type BuildHypercoreTransactionRequest, type BuildHypercoreTransactionResponse, type BuildSolanaTransactionRequest, type BuildSolanaTransactionResponse, type CashAppLimits, type CashAppSessionRequest, type CashAppSessionResponse, type CashAppSessionStatusResponse, type ChainType, type CreateDepositAddressRequest, type CreateExchangeSessionRequest, type CreateExchangeSessionResponse, type DefaultTokenChain, type DefaultTokenMetadata, type DefaultTokenResponse, type DepositAddressResponse, type DepositEvent, DepositEventType, type DepositQuote, type DepositQuoteRequest, type DestinationToken, type DestinationTokenChain, type ExchangeProviderInfo, type ExchangeProvidersResponse, type ExchangeSessionStartParams, type ExchangeWalletAddress, ExecutionStatus, type FeaturedToken, type FeaturedWallet, type FiatCurrenciesResponse, type FiatCurrency, type GetExchangesQuery, type HypercoreActionType, type HypercoreActivationRequest, type HypercoreActivationResponse, type I18nStrings, type IconUrl, IneligibilityReason, type IpAddressResponse, type LockedQuoteLimits, type LockedQuotePreview, type LockedQuotePreviewRequest, type OnrampQuote, type OnrampQuotesRequest, type OnrampQuotesResponse, type OnrampSessionCreatedData, type OnrampSessionCreatedEvent, type OnrampSessionRequest, type OnrampSessionResponse, type PaymentIntent, type PaymentIntentDepositAddress, type PaymentIntentExecutionsResponse, type PaymentIntentStatus, type PaymentIntentType, type PaymentNetwork, type PollExecutionsRequest, type PollExecutionsResponse, type ProductType, type ProjectConfigResponse, type QueryExecutionsRequest, type QueryExecutionsResponse, SOLANA_USDC_ADDRESS, type SendHypercoreTransactionRequest, type SendHypercoreTransactionResponse, type SendSolanaTransactionRequest, type SendSolanaTransactionResponse, type SourceToken, type SourceTokenNetwork, type SupportedChain, type SupportedDepositTokensResponse, type SupportedDestinationTokensResponse, type SupportedSourceTokensQuery, type SupportedSourceTokensResponse, type SupportedToken, type TokenBalance, type TokenChain, type TokenChainIconUrl, type TokenChainsResponse, type TokenIconUrl, type TokenInfo, type TokenMetadata, type UserIpInfo, type VerifyAddressRequest, type VerifyAddressResponse, type Wallet, buildHypercoreTransaction, buildSolanaTransaction, checkHypercoreActivation, createCashAppSession, createDepositAddress, createExchangeSession, createOnrampSession, formatStablecoinAmount, generatePrefixedKSUID, getAddressBalance, getAddressBalances, getApiBaseUrl, getCashAppLimits, getCashAppSessionStatus, getChainName, getDefaultOnrampToken, getDepositQuote, getExchangeSessionStartUrl, getExchanges, getFiatCurrencies, getIconUrl, getIconUrlWithCdn, getIpAddress, getOnrampQuotes, getOnrampSessionStartUrl, getPreferredIconUrl, getProjectConfig, getSupportedDepositTokens, getSupportedDestinationTokens, getTokenChains, getTokenMetadata, getWalletByChainType, i18n, listPaymentIntentExecutions, pollDirectExecutions, queryExecutions, retrievePaymentIntent, sendHypercoreTransaction, sendSolanaTransaction, setApiConfig, useUserIp, verifyRecipientAddress };
|
package/dist/index.d.ts
CHANGED
|
@@ -76,6 +76,7 @@ interface IconUrl {
|
|
|
76
76
|
url: string;
|
|
77
77
|
format: "svg" | "png";
|
|
78
78
|
}
|
|
79
|
+
type ProductType = "deposit" | "payment";
|
|
79
80
|
interface AutoSwapResponse {
|
|
80
81
|
id: string;
|
|
81
82
|
project_id: string;
|
|
@@ -157,6 +158,7 @@ interface SupportedChain {
|
|
|
157
158
|
chain_type: string;
|
|
158
159
|
icon_url: string;
|
|
159
160
|
token_address: string;
|
|
161
|
+
decimals: number;
|
|
160
162
|
estimated_price_impact_percent: number;
|
|
161
163
|
max_slippage_percent: number;
|
|
162
164
|
estimated_processing_time: number | null;
|
|
@@ -184,13 +186,17 @@ interface SupportedDestinationTokensResponse {
|
|
|
184
186
|
/**
|
|
185
187
|
* Get supported destination tokens (used for withdraw flow)
|
|
186
188
|
* @param publishableKey - Optional publishable key, defaults to configured key
|
|
189
|
+
* @param options - Optional query parameters
|
|
187
190
|
*/
|
|
188
|
-
declare function getSupportedDestinationTokens(publishableKey?: string
|
|
191
|
+
declare function getSupportedDestinationTokens(publishableKey?: string, options?: {
|
|
192
|
+
product_type?: ProductType;
|
|
193
|
+
}): Promise<SupportedDestinationTokensResponse>;
|
|
189
194
|
interface SupportedToken {
|
|
190
195
|
symbol: string;
|
|
191
196
|
name: string;
|
|
192
197
|
icon_url: string;
|
|
193
198
|
is_newly_added: boolean;
|
|
199
|
+
is_stablecoin: boolean;
|
|
194
200
|
chains: SupportedChain[];
|
|
195
201
|
}
|
|
196
202
|
interface SupportedDepositTokensResponse {
|
|
@@ -204,7 +210,7 @@ declare function getSupportedDepositTokens(publishableKey?: string, options?: {
|
|
|
204
210
|
destination_token_address?: string;
|
|
205
211
|
destination_chain_id?: string;
|
|
206
212
|
destination_chain_type?: string;
|
|
207
|
-
product_type?:
|
|
213
|
+
product_type?: ProductType;
|
|
208
214
|
}): Promise<SupportedDepositTokensResponse>;
|
|
209
215
|
interface TokenMetadata {
|
|
210
216
|
symbol: string;
|
|
@@ -407,12 +413,20 @@ interface BlockedCountrySubdivision {
|
|
|
407
413
|
country_code: string;
|
|
408
414
|
subdivision_codes: string[];
|
|
409
415
|
}
|
|
416
|
+
interface FeaturedWallet {
|
|
417
|
+
name: string;
|
|
418
|
+
position: number;
|
|
419
|
+
icon_urls: IconUrl[];
|
|
420
|
+
}
|
|
410
421
|
interface ProjectConfigResponse {
|
|
411
422
|
project_name?: string;
|
|
412
423
|
asset_cdn_url: string;
|
|
413
424
|
transfer_crypto: {
|
|
414
425
|
networks: FeaturedToken[];
|
|
415
426
|
};
|
|
427
|
+
connect_wallet: {
|
|
428
|
+
wallets: FeaturedWallet[];
|
|
429
|
+
};
|
|
416
430
|
payment_networks: {
|
|
417
431
|
networks: PaymentNetwork[];
|
|
418
432
|
};
|
|
@@ -753,6 +767,8 @@ interface PaymentIntent {
|
|
|
753
767
|
description: string | null;
|
|
754
768
|
livemode: boolean;
|
|
755
769
|
settlement_tolerance_percent: number;
|
|
770
|
+
/** When true, stablecoin deposits are credited at par (1:1) regardless of swap slippage. */
|
|
771
|
+
stablecoin_parity: boolean;
|
|
756
772
|
canceled_at: string | null;
|
|
757
773
|
cancellation_reason: string | null;
|
|
758
774
|
expires_at: string | null;
|
|
@@ -888,6 +904,11 @@ interface DepositQuoteRequest {
|
|
|
888
904
|
* reduce stuck payments. Typically set by the checkout flow.
|
|
889
905
|
*/
|
|
890
906
|
adjust_for_slippage?: boolean;
|
|
907
|
+
/**
|
|
908
|
+
* When true and both tokens are stablecoins, returns a 1:1 quote
|
|
909
|
+
* without calling the swap provider. Ignored if source is not a stablecoin.
|
|
910
|
+
*/
|
|
911
|
+
stablecoin_parity?: boolean;
|
|
891
912
|
}
|
|
892
913
|
interface DepositQuote {
|
|
893
914
|
/**
|
|
@@ -959,8 +980,53 @@ declare function buildHypercoreTransaction(request: BuildHypercoreTransactionReq
|
|
|
959
980
|
* Pass the action + nonce from buildHypercoreTransaction and
|
|
960
981
|
* the signature from eth_signTypedData_v4.
|
|
961
982
|
*/
|
|
983
|
+
interface CashAppSessionRequest {
|
|
984
|
+
external_user_id: string;
|
|
985
|
+
destination_chain_type: string;
|
|
986
|
+
destination_chain_id: string;
|
|
987
|
+
destination_token_address: string;
|
|
988
|
+
recipient_address: string;
|
|
989
|
+
source_amount: string;
|
|
990
|
+
external_id?: string;
|
|
991
|
+
}
|
|
992
|
+
interface CashAppSessionResponse {
|
|
993
|
+
id: string;
|
|
994
|
+
external_id: string;
|
|
995
|
+
url: string;
|
|
996
|
+
status: string;
|
|
997
|
+
destination_amount: string;
|
|
998
|
+
expires_at: string;
|
|
999
|
+
}
|
|
1000
|
+
interface CashAppSessionStatusResponse {
|
|
1001
|
+
status: string;
|
|
1002
|
+
updated_at?: string;
|
|
1003
|
+
}
|
|
1004
|
+
interface CashAppLimits {
|
|
1005
|
+
minimum_amount: number;
|
|
1006
|
+
maximum_amount: number | null;
|
|
1007
|
+
currency: string;
|
|
1008
|
+
}
|
|
1009
|
+
declare function getCashAppLimits(currency?: string, publishableKey?: string): Promise<CashAppLimits>;
|
|
1010
|
+
declare function createCashAppSession(request: CashAppSessionRequest, publishableKey?: string): Promise<CashAppSessionResponse>;
|
|
1011
|
+
declare function getCashAppSessionStatus(externalId: string, publishableKey?: string): Promise<CashAppSessionStatusResponse>;
|
|
962
1012
|
declare function sendHypercoreTransaction(request: SendHypercoreTransactionRequest, publishableKey?: string): Promise<SendHypercoreTransactionResponse>;
|
|
963
1013
|
|
|
1014
|
+
/**
|
|
1015
|
+
* Format a stablecoin amount to 2 decimal places, ceiling any fractional
|
|
1016
|
+
* value beyond the 2nd decimal. This ensures the displayed amount is always
|
|
1017
|
+
* >= the real amount, so the user never underpays.
|
|
1018
|
+
*
|
|
1019
|
+
* @param baseUnits - Amount in base units (e.g. "5123456")
|
|
1020
|
+
* @param decimals - Token decimals (e.g. 6 for USDC)
|
|
1021
|
+
* @returns Formatted string with exactly 2 decimal places (e.g. "5.13")
|
|
1022
|
+
*
|
|
1023
|
+
* @example
|
|
1024
|
+
* formatStablecoinAmount("5123456", 6) // "5.13" (5.123456 → ceil)
|
|
1025
|
+
* formatStablecoinAmount("5120000", 6) // "5.12" (exact, no rounding)
|
|
1026
|
+
* formatStablecoinAmount("3450050", 6) // "3.46" (3.450050 → ceil)
|
|
1027
|
+
* formatStablecoinAmount("10000000", 6) // "10.00" (whole number)
|
|
1028
|
+
*/
|
|
1029
|
+
declare function formatStablecoinAmount(baseUnits: string, decimals: number): string;
|
|
964
1030
|
/**
|
|
965
1031
|
* Generate a KSUID-like prefixed ID without external dependencies.
|
|
966
1032
|
* Format: `{prefix}_{base62(4-byte-timestamp + 16-random-bytes)}` (27 chars after prefix).
|
|
@@ -1123,4 +1189,4 @@ declare const i18n: {
|
|
|
1123
1189
|
};
|
|
1124
1190
|
type I18nStrings = typeof i18n;
|
|
1125
1191
|
|
|
1126
|
-
export { ActionType, type AddressBalanceResponse, type AddressBalancesResponse, type AddressValidationFailureCode, type AddressValidationMetadata, type AutoSwapRequest, type AutoSwapResponse, type BlockedCountrySubdivision, type BuildHypercoreTransactionRequest, type BuildHypercoreTransactionResponse, type BuildSolanaTransactionRequest, type BuildSolanaTransactionResponse, type ChainType, type CreateDepositAddressRequest, type CreateExchangeSessionRequest, type CreateExchangeSessionResponse, type DefaultTokenChain, type DefaultTokenMetadata, type DefaultTokenResponse, type DepositAddressResponse, type DepositEvent, DepositEventType, type DepositQuote, type DepositQuoteRequest, type DestinationToken, type DestinationTokenChain, type ExchangeProviderInfo, type ExchangeProvidersResponse, type ExchangeSessionStartParams, type ExchangeWalletAddress, ExecutionStatus, type FeaturedToken, type FiatCurrenciesResponse, type FiatCurrency, type GetExchangesQuery, type HypercoreActionType, type HypercoreActivationRequest, type HypercoreActivationResponse, type I18nStrings, type IconUrl, IneligibilityReason, type IpAddressResponse, type LockedQuoteLimits, type LockedQuotePreview, type LockedQuotePreviewRequest, type OnrampQuote, type OnrampQuotesRequest, type OnrampQuotesResponse, type OnrampSessionCreatedData, type OnrampSessionCreatedEvent, type OnrampSessionRequest, type OnrampSessionResponse, type PaymentIntent, type PaymentIntentDepositAddress, type PaymentIntentExecutionsResponse, type PaymentIntentStatus, type PaymentIntentType, type PaymentNetwork, type PollExecutionsRequest, type PollExecutionsResponse, type ProjectConfigResponse, type QueryExecutionsRequest, type QueryExecutionsResponse, SOLANA_USDC_ADDRESS, type SendHypercoreTransactionRequest, type SendHypercoreTransactionResponse, type SendSolanaTransactionRequest, type SendSolanaTransactionResponse, type SourceToken, type SourceTokenNetwork, type SupportedChain, type SupportedDepositTokensResponse, type SupportedDestinationTokensResponse, type SupportedSourceTokensQuery, type SupportedSourceTokensResponse, type SupportedToken, type TokenBalance, type TokenChain, type TokenChainIconUrl, type TokenChainsResponse, type TokenIconUrl, type TokenInfo, type TokenMetadata, type UserIpInfo, type VerifyAddressRequest, type VerifyAddressResponse, type Wallet, buildHypercoreTransaction, buildSolanaTransaction, checkHypercoreActivation, createDepositAddress, createExchangeSession, createOnrampSession, generatePrefixedKSUID, getAddressBalance, getAddressBalances, getApiBaseUrl, getChainName, getDefaultOnrampToken, getDepositQuote, getExchangeSessionStartUrl, getExchanges, getFiatCurrencies, getIconUrl, getIconUrlWithCdn, getIpAddress, getOnrampQuotes, getOnrampSessionStartUrl, getPreferredIconUrl, getProjectConfig, getSupportedDepositTokens, getSupportedDestinationTokens, getTokenChains, getTokenMetadata, getWalletByChainType, i18n, listPaymentIntentExecutions, pollDirectExecutions, queryExecutions, retrievePaymentIntent, sendHypercoreTransaction, sendSolanaTransaction, setApiConfig, useUserIp, verifyRecipientAddress };
|
|
1192
|
+
export { ActionType, type AddressBalanceResponse, type AddressBalancesResponse, type AddressValidationFailureCode, type AddressValidationMetadata, type AutoSwapRequest, type AutoSwapResponse, type BlockedCountrySubdivision, type BuildHypercoreTransactionRequest, type BuildHypercoreTransactionResponse, type BuildSolanaTransactionRequest, type BuildSolanaTransactionResponse, type CashAppLimits, type CashAppSessionRequest, type CashAppSessionResponse, type CashAppSessionStatusResponse, type ChainType, type CreateDepositAddressRequest, type CreateExchangeSessionRequest, type CreateExchangeSessionResponse, type DefaultTokenChain, type DefaultTokenMetadata, type DefaultTokenResponse, type DepositAddressResponse, type DepositEvent, DepositEventType, type DepositQuote, type DepositQuoteRequest, type DestinationToken, type DestinationTokenChain, type ExchangeProviderInfo, type ExchangeProvidersResponse, type ExchangeSessionStartParams, type ExchangeWalletAddress, ExecutionStatus, type FeaturedToken, type FeaturedWallet, type FiatCurrenciesResponse, type FiatCurrency, type GetExchangesQuery, type HypercoreActionType, type HypercoreActivationRequest, type HypercoreActivationResponse, type I18nStrings, type IconUrl, IneligibilityReason, type IpAddressResponse, type LockedQuoteLimits, type LockedQuotePreview, type LockedQuotePreviewRequest, type OnrampQuote, type OnrampQuotesRequest, type OnrampQuotesResponse, type OnrampSessionCreatedData, type OnrampSessionCreatedEvent, type OnrampSessionRequest, type OnrampSessionResponse, type PaymentIntent, type PaymentIntentDepositAddress, type PaymentIntentExecutionsResponse, type PaymentIntentStatus, type PaymentIntentType, type PaymentNetwork, type PollExecutionsRequest, type PollExecutionsResponse, type ProductType, type ProjectConfigResponse, type QueryExecutionsRequest, type QueryExecutionsResponse, SOLANA_USDC_ADDRESS, type SendHypercoreTransactionRequest, type SendHypercoreTransactionResponse, type SendSolanaTransactionRequest, type SendSolanaTransactionResponse, type SourceToken, type SourceTokenNetwork, type SupportedChain, type SupportedDepositTokensResponse, type SupportedDestinationTokensResponse, type SupportedSourceTokensQuery, type SupportedSourceTokensResponse, type SupportedToken, type TokenBalance, type TokenChain, type TokenChainIconUrl, type TokenChainsResponse, type TokenIconUrl, type TokenInfo, type TokenMetadata, type UserIpInfo, type VerifyAddressRequest, type VerifyAddressResponse, type Wallet, buildHypercoreTransaction, buildSolanaTransaction, checkHypercoreActivation, createCashAppSession, createDepositAddress, createExchangeSession, createOnrampSession, formatStablecoinAmount, generatePrefixedKSUID, getAddressBalance, getAddressBalances, getApiBaseUrl, getCashAppLimits, getCashAppSessionStatus, getChainName, getDefaultOnrampToken, getDepositQuote, getExchangeSessionStartUrl, getExchanges, getFiatCurrencies, getIconUrl, getIconUrlWithCdn, getIpAddress, getOnrampQuotes, getOnrampSessionStartUrl, getPreferredIconUrl, getProjectConfig, getSupportedDepositTokens, getSupportedDestinationTokens, getTokenChains, getTokenMetadata, getWalletByChainType, i18n, listPaymentIntentExecutions, pollDirectExecutions, queryExecutions, retrievePaymentIntent, sendHypercoreTransaction, sendSolanaTransaction, setApiConfig, useUserIp, verifyRecipientAddress };
|
package/dist/index.js
CHANGED
|
@@ -28,13 +28,17 @@ __export(index_exports, {
|
|
|
28
28
|
buildHypercoreTransaction: () => buildHypercoreTransaction,
|
|
29
29
|
buildSolanaTransaction: () => buildSolanaTransaction,
|
|
30
30
|
checkHypercoreActivation: () => checkHypercoreActivation,
|
|
31
|
+
createCashAppSession: () => createCashAppSession,
|
|
31
32
|
createDepositAddress: () => createDepositAddress,
|
|
32
33
|
createExchangeSession: () => createExchangeSession,
|
|
33
34
|
createOnrampSession: () => createOnrampSession,
|
|
35
|
+
formatStablecoinAmount: () => formatStablecoinAmount,
|
|
34
36
|
generatePrefixedKSUID: () => generatePrefixedKSUID,
|
|
35
37
|
getAddressBalance: () => getAddressBalance,
|
|
36
38
|
getAddressBalances: () => getAddressBalances,
|
|
37
39
|
getApiBaseUrl: () => getApiBaseUrl,
|
|
40
|
+
getCashAppLimits: () => getCashAppLimits,
|
|
41
|
+
getCashAppSessionStatus: () => getCashAppSessionStatus,
|
|
38
42
|
getChainName: () => getChainName,
|
|
39
43
|
getDefaultOnrampToken: () => getDefaultOnrampToken,
|
|
40
44
|
getDepositQuote: () => getDepositQuote,
|
|
@@ -210,19 +214,25 @@ async function pollDirectExecutions(request, publishableKey) {
|
|
|
210
214
|
}
|
|
211
215
|
return response.json();
|
|
212
216
|
}
|
|
213
|
-
async function getSupportedDestinationTokens(publishableKey) {
|
|
217
|
+
async function getSupportedDestinationTokens(publishableKey, options) {
|
|
214
218
|
const pk = publishableKey || DEFAULT_PUBLISHABLE_KEY;
|
|
215
219
|
validatePublishableKey(pk);
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
220
|
+
let url = `${API_BASE_URL}/v1/public/tokens/supported_destination_tokens`;
|
|
221
|
+
const params = new URLSearchParams();
|
|
222
|
+
if (options?.product_type) {
|
|
223
|
+
params.set("product_type", options.product_type);
|
|
224
|
+
}
|
|
225
|
+
const qs = params.toString();
|
|
226
|
+
if (qs) {
|
|
227
|
+
url = `${url}?${qs}`;
|
|
228
|
+
}
|
|
229
|
+
const response = await fetch(url, {
|
|
230
|
+
method: "GET",
|
|
231
|
+
headers: {
|
|
232
|
+
accept: "application/json",
|
|
233
|
+
"x-publishable-key": pk
|
|
224
234
|
}
|
|
225
|
-
);
|
|
235
|
+
});
|
|
226
236
|
if (!response.ok) {
|
|
227
237
|
throw new Error(
|
|
228
238
|
`Failed to fetch supported destination tokens: ${response.statusText}`
|
|
@@ -737,6 +747,71 @@ async function buildHypercoreTransaction(request, publishableKey) {
|
|
|
737
747
|
}
|
|
738
748
|
return response.json();
|
|
739
749
|
}
|
|
750
|
+
async function getCashAppLimits(currency = "usd", publishableKey) {
|
|
751
|
+
const pk = publishableKey || DEFAULT_PUBLISHABLE_KEY;
|
|
752
|
+
validatePublishableKey(pk);
|
|
753
|
+
const response = await fetch(
|
|
754
|
+
`${API_BASE_URL}/v1/public/onramps/cashapp/limits?currency=${encodeURIComponent(currency)}`,
|
|
755
|
+
{
|
|
756
|
+
method: "GET",
|
|
757
|
+
headers: {
|
|
758
|
+
accept: "application/json",
|
|
759
|
+
"x-publishable-key": pk
|
|
760
|
+
}
|
|
761
|
+
}
|
|
762
|
+
);
|
|
763
|
+
if (!response.ok) {
|
|
764
|
+
const error = await response.json().catch(() => ({ message: response.statusText }));
|
|
765
|
+
throw new Error(
|
|
766
|
+
`Failed to get Cash App limits: ${error.message || response.statusText}`
|
|
767
|
+
);
|
|
768
|
+
}
|
|
769
|
+
return response.json();
|
|
770
|
+
}
|
|
771
|
+
async function createCashAppSession(request, publishableKey) {
|
|
772
|
+
const pk = publishableKey || DEFAULT_PUBLISHABLE_KEY;
|
|
773
|
+
validatePublishableKey(pk);
|
|
774
|
+
const response = await fetch(
|
|
775
|
+
`${API_BASE_URL}/v1/public/onramps/cashapp/sessions`,
|
|
776
|
+
{
|
|
777
|
+
method: "POST",
|
|
778
|
+
headers: {
|
|
779
|
+
accept: "application/json",
|
|
780
|
+
"x-publishable-key": pk,
|
|
781
|
+
"Content-Type": "application/json"
|
|
782
|
+
},
|
|
783
|
+
body: JSON.stringify(request)
|
|
784
|
+
}
|
|
785
|
+
);
|
|
786
|
+
if (!response.ok) {
|
|
787
|
+
const error = await response.json().catch(() => ({ message: response.statusText }));
|
|
788
|
+
throw new Error(
|
|
789
|
+
`Failed to create Cash App session: ${error.message || response.statusText}`
|
|
790
|
+
);
|
|
791
|
+
}
|
|
792
|
+
return response.json();
|
|
793
|
+
}
|
|
794
|
+
async function getCashAppSessionStatus(externalId, publishableKey) {
|
|
795
|
+
const pk = publishableKey || DEFAULT_PUBLISHABLE_KEY;
|
|
796
|
+
validatePublishableKey(pk);
|
|
797
|
+
const response = await fetch(
|
|
798
|
+
`${API_BASE_URL}/v1/public/onramps/cashapp/sessions/${encodeURIComponent(externalId)}/status`,
|
|
799
|
+
{
|
|
800
|
+
method: "GET",
|
|
801
|
+
headers: {
|
|
802
|
+
accept: "application/json",
|
|
803
|
+
"x-publishable-key": pk
|
|
804
|
+
}
|
|
805
|
+
}
|
|
806
|
+
);
|
|
807
|
+
if (!response.ok) {
|
|
808
|
+
const error = await response.json().catch(() => ({ message: response.statusText }));
|
|
809
|
+
throw new Error(
|
|
810
|
+
`Failed to get Cash App session status: ${error.message || response.statusText}`
|
|
811
|
+
);
|
|
812
|
+
}
|
|
813
|
+
return response.json();
|
|
814
|
+
}
|
|
740
815
|
async function sendHypercoreTransaction(request, publishableKey) {
|
|
741
816
|
const pk = publishableKey || DEFAULT_PUBLISHABLE_KEY;
|
|
742
817
|
validatePublishableKey(pk);
|
|
@@ -762,6 +837,12 @@ async function sendHypercoreTransaction(request, publishableKey) {
|
|
|
762
837
|
}
|
|
763
838
|
|
|
764
839
|
// src/lib/utils.ts
|
|
840
|
+
function formatStablecoinAmount(baseUnits, decimals) {
|
|
841
|
+
const raw = Number(baseUnits) / 10 ** decimals;
|
|
842
|
+
const floored = Math.floor(raw * 100) / 100;
|
|
843
|
+
const ceiled = raw > floored ? floored + 0.01 : raw;
|
|
844
|
+
return ceiled.toFixed(2);
|
|
845
|
+
}
|
|
765
846
|
function generatePrefixedKSUID(prefix) {
|
|
766
847
|
const BASE62 = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
|
|
767
848
|
const KSUID_EPOCH = 14e8;
|
|
@@ -808,10 +889,10 @@ function useUserIp() {
|
|
|
808
889
|
queryKey: ["unifold", "userIpInfo"],
|
|
809
890
|
queryFn: async () => {
|
|
810
891
|
const data = await getIpAddress();
|
|
811
|
-
const subdivision =
|
|
892
|
+
const subdivision = data.subdivision_code || data.state || "" || null;
|
|
812
893
|
return {
|
|
813
|
-
alpha2: data.alpha2
|
|
814
|
-
alpha3: data.alpha3
|
|
894
|
+
alpha2: data.alpha2,
|
|
895
|
+
alpha3: data.alpha3,
|
|
815
896
|
country: data.country,
|
|
816
897
|
state: subdivision,
|
|
817
898
|
subdivisionCode: subdivision,
|
|
@@ -938,13 +1019,17 @@ var i18n = en_default;
|
|
|
938
1019
|
buildHypercoreTransaction,
|
|
939
1020
|
buildSolanaTransaction,
|
|
940
1021
|
checkHypercoreActivation,
|
|
1022
|
+
createCashAppSession,
|
|
941
1023
|
createDepositAddress,
|
|
942
1024
|
createExchangeSession,
|
|
943
1025
|
createOnrampSession,
|
|
1026
|
+
formatStablecoinAmount,
|
|
944
1027
|
generatePrefixedKSUID,
|
|
945
1028
|
getAddressBalance,
|
|
946
1029
|
getAddressBalances,
|
|
947
1030
|
getApiBaseUrl,
|
|
1031
|
+
getCashAppLimits,
|
|
1032
|
+
getCashAppSessionStatus,
|
|
948
1033
|
getChainName,
|
|
949
1034
|
getDefaultOnrampToken,
|
|
950
1035
|
getDepositQuote,
|
package/dist/index.mjs
CHANGED
|
@@ -142,19 +142,25 @@ async function pollDirectExecutions(request, publishableKey) {
|
|
|
142
142
|
}
|
|
143
143
|
return response.json();
|
|
144
144
|
}
|
|
145
|
-
async function getSupportedDestinationTokens(publishableKey) {
|
|
145
|
+
async function getSupportedDestinationTokens(publishableKey, options) {
|
|
146
146
|
const pk = publishableKey || DEFAULT_PUBLISHABLE_KEY;
|
|
147
147
|
validatePublishableKey(pk);
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
148
|
+
let url = `${API_BASE_URL}/v1/public/tokens/supported_destination_tokens`;
|
|
149
|
+
const params = new URLSearchParams();
|
|
150
|
+
if (options?.product_type) {
|
|
151
|
+
params.set("product_type", options.product_type);
|
|
152
|
+
}
|
|
153
|
+
const qs = params.toString();
|
|
154
|
+
if (qs) {
|
|
155
|
+
url = `${url}?${qs}`;
|
|
156
|
+
}
|
|
157
|
+
const response = await fetch(url, {
|
|
158
|
+
method: "GET",
|
|
159
|
+
headers: {
|
|
160
|
+
accept: "application/json",
|
|
161
|
+
"x-publishable-key": pk
|
|
156
162
|
}
|
|
157
|
-
);
|
|
163
|
+
});
|
|
158
164
|
if (!response.ok) {
|
|
159
165
|
throw new Error(
|
|
160
166
|
`Failed to fetch supported destination tokens: ${response.statusText}`
|
|
@@ -669,6 +675,71 @@ async function buildHypercoreTransaction(request, publishableKey) {
|
|
|
669
675
|
}
|
|
670
676
|
return response.json();
|
|
671
677
|
}
|
|
678
|
+
async function getCashAppLimits(currency = "usd", publishableKey) {
|
|
679
|
+
const pk = publishableKey || DEFAULT_PUBLISHABLE_KEY;
|
|
680
|
+
validatePublishableKey(pk);
|
|
681
|
+
const response = await fetch(
|
|
682
|
+
`${API_BASE_URL}/v1/public/onramps/cashapp/limits?currency=${encodeURIComponent(currency)}`,
|
|
683
|
+
{
|
|
684
|
+
method: "GET",
|
|
685
|
+
headers: {
|
|
686
|
+
accept: "application/json",
|
|
687
|
+
"x-publishable-key": pk
|
|
688
|
+
}
|
|
689
|
+
}
|
|
690
|
+
);
|
|
691
|
+
if (!response.ok) {
|
|
692
|
+
const error = await response.json().catch(() => ({ message: response.statusText }));
|
|
693
|
+
throw new Error(
|
|
694
|
+
`Failed to get Cash App limits: ${error.message || response.statusText}`
|
|
695
|
+
);
|
|
696
|
+
}
|
|
697
|
+
return response.json();
|
|
698
|
+
}
|
|
699
|
+
async function createCashAppSession(request, publishableKey) {
|
|
700
|
+
const pk = publishableKey || DEFAULT_PUBLISHABLE_KEY;
|
|
701
|
+
validatePublishableKey(pk);
|
|
702
|
+
const response = await fetch(
|
|
703
|
+
`${API_BASE_URL}/v1/public/onramps/cashapp/sessions`,
|
|
704
|
+
{
|
|
705
|
+
method: "POST",
|
|
706
|
+
headers: {
|
|
707
|
+
accept: "application/json",
|
|
708
|
+
"x-publishable-key": pk,
|
|
709
|
+
"Content-Type": "application/json"
|
|
710
|
+
},
|
|
711
|
+
body: JSON.stringify(request)
|
|
712
|
+
}
|
|
713
|
+
);
|
|
714
|
+
if (!response.ok) {
|
|
715
|
+
const error = await response.json().catch(() => ({ message: response.statusText }));
|
|
716
|
+
throw new Error(
|
|
717
|
+
`Failed to create Cash App session: ${error.message || response.statusText}`
|
|
718
|
+
);
|
|
719
|
+
}
|
|
720
|
+
return response.json();
|
|
721
|
+
}
|
|
722
|
+
async function getCashAppSessionStatus(externalId, publishableKey) {
|
|
723
|
+
const pk = publishableKey || DEFAULT_PUBLISHABLE_KEY;
|
|
724
|
+
validatePublishableKey(pk);
|
|
725
|
+
const response = await fetch(
|
|
726
|
+
`${API_BASE_URL}/v1/public/onramps/cashapp/sessions/${encodeURIComponent(externalId)}/status`,
|
|
727
|
+
{
|
|
728
|
+
method: "GET",
|
|
729
|
+
headers: {
|
|
730
|
+
accept: "application/json",
|
|
731
|
+
"x-publishable-key": pk
|
|
732
|
+
}
|
|
733
|
+
}
|
|
734
|
+
);
|
|
735
|
+
if (!response.ok) {
|
|
736
|
+
const error = await response.json().catch(() => ({ message: response.statusText }));
|
|
737
|
+
throw new Error(
|
|
738
|
+
`Failed to get Cash App session status: ${error.message || response.statusText}`
|
|
739
|
+
);
|
|
740
|
+
}
|
|
741
|
+
return response.json();
|
|
742
|
+
}
|
|
672
743
|
async function sendHypercoreTransaction(request, publishableKey) {
|
|
673
744
|
const pk = publishableKey || DEFAULT_PUBLISHABLE_KEY;
|
|
674
745
|
validatePublishableKey(pk);
|
|
@@ -694,6 +765,12 @@ async function sendHypercoreTransaction(request, publishableKey) {
|
|
|
694
765
|
}
|
|
695
766
|
|
|
696
767
|
// src/lib/utils.ts
|
|
768
|
+
function formatStablecoinAmount(baseUnits, decimals) {
|
|
769
|
+
const raw = Number(baseUnits) / 10 ** decimals;
|
|
770
|
+
const floored = Math.floor(raw * 100) / 100;
|
|
771
|
+
const ceiled = raw > floored ? floored + 0.01 : raw;
|
|
772
|
+
return ceiled.toFixed(2);
|
|
773
|
+
}
|
|
697
774
|
function generatePrefixedKSUID(prefix) {
|
|
698
775
|
const BASE62 = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
|
|
699
776
|
const KSUID_EPOCH = 14e8;
|
|
@@ -740,10 +817,10 @@ function useUserIp() {
|
|
|
740
817
|
queryKey: ["unifold", "userIpInfo"],
|
|
741
818
|
queryFn: async () => {
|
|
742
819
|
const data = await getIpAddress();
|
|
743
|
-
const subdivision =
|
|
820
|
+
const subdivision = data.subdivision_code || data.state || "" || null;
|
|
744
821
|
return {
|
|
745
|
-
alpha2: data.alpha2
|
|
746
|
-
alpha3: data.alpha3
|
|
822
|
+
alpha2: data.alpha2,
|
|
823
|
+
alpha3: data.alpha3,
|
|
747
824
|
country: data.country,
|
|
748
825
|
state: subdivision,
|
|
749
826
|
subdivisionCode: subdivision,
|
|
@@ -869,13 +946,17 @@ export {
|
|
|
869
946
|
buildHypercoreTransaction,
|
|
870
947
|
buildSolanaTransaction,
|
|
871
948
|
checkHypercoreActivation,
|
|
949
|
+
createCashAppSession,
|
|
872
950
|
createDepositAddress,
|
|
873
951
|
createExchangeSession,
|
|
874
952
|
createOnrampSession,
|
|
953
|
+
formatStablecoinAmount,
|
|
875
954
|
generatePrefixedKSUID,
|
|
876
955
|
getAddressBalance,
|
|
877
956
|
getAddressBalances,
|
|
878
957
|
getApiBaseUrl,
|
|
958
|
+
getCashAppLimits,
|
|
959
|
+
getCashAppSessionStatus,
|
|
879
960
|
getChainName,
|
|
880
961
|
getDefaultOnrampToken,
|
|
881
962
|
getDepositQuote,
|