@unifold/core 0.1.62 → 0.1.64
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 +89 -1
- package/dist/index.d.ts +89 -1
- package/dist/index.js +80 -42
- package/dist/index.mjs +77 -42
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -457,9 +457,11 @@ interface ProjectConfigResponse {
|
|
|
457
457
|
project_name?: string;
|
|
458
458
|
asset_cdn_url: string;
|
|
459
459
|
transfer_crypto: {
|
|
460
|
+
enabled?: boolean;
|
|
460
461
|
networks: FeaturedToken[];
|
|
461
462
|
};
|
|
462
463
|
connect_wallet: {
|
|
464
|
+
enabled?: boolean;
|
|
463
465
|
wallets: FeaturedWallet[];
|
|
464
466
|
};
|
|
465
467
|
payment_networks: {
|
|
@@ -467,12 +469,21 @@ interface ProjectConfigResponse {
|
|
|
467
469
|
};
|
|
468
470
|
blocked_country_codes?: string[];
|
|
469
471
|
blocked_country_subdivisions?: BlockedCountrySubdivision[];
|
|
472
|
+
connect_exchange?: {
|
|
473
|
+
enabled: boolean;
|
|
474
|
+
};
|
|
475
|
+
cash_app?: {
|
|
476
|
+
enabled: boolean;
|
|
477
|
+
};
|
|
470
478
|
pay_with_exchange?: {
|
|
471
479
|
enabled: boolean;
|
|
472
480
|
};
|
|
473
481
|
fiat_onramp?: {
|
|
474
482
|
enabled: boolean;
|
|
475
483
|
};
|
|
484
|
+
deposit_tracker?: {
|
|
485
|
+
enabled: boolean;
|
|
486
|
+
};
|
|
476
487
|
hypercore_sponsorship?: {
|
|
477
488
|
enabled: boolean;
|
|
478
489
|
};
|
|
@@ -540,6 +551,78 @@ interface AddressBalancesResponse {
|
|
|
540
551
|
* @param publishableKey - Optional publishable key, defaults to configured key
|
|
541
552
|
*/
|
|
542
553
|
declare function getAddressBalances(address: string, chainType: ChainType, publishableKey?: string): Promise<AddressBalancesResponse>;
|
|
554
|
+
/** Wallet ids supported by the connect-wallet flow. */
|
|
555
|
+
type WalletMobileDeepLinkWallet = "phantom" | "metamask" | "coinbase" | "trust" | "rainbow" | "rabby" | "okx";
|
|
556
|
+
/** Chain types an external wallet can connect on. */
|
|
557
|
+
type ExternalWalletChainType = "ethereum" | "solana";
|
|
558
|
+
/** A supported external (self-custody) wallet from the directory endpoint. */
|
|
559
|
+
interface ExternalWalletInfo {
|
|
560
|
+
id: WalletMobileDeepLinkWallet;
|
|
561
|
+
name: string;
|
|
562
|
+
chain_types: ExternalWalletChainType[];
|
|
563
|
+
install_url: string;
|
|
564
|
+
icon_url: string;
|
|
565
|
+
icon_urls: Array<{
|
|
566
|
+
url: string;
|
|
567
|
+
format: "svg" | "png";
|
|
568
|
+
}>;
|
|
569
|
+
/** Whether the wallet can be opened into its in-app browser on mobile. */
|
|
570
|
+
supports_mobile_browse: boolean;
|
|
571
|
+
/**
|
|
572
|
+
* Mobile platforms the in-app browser deep link works on.
|
|
573
|
+
* `null` means all platforms; an explicit list (e.g. `["ios"]`) tells the
|
|
574
|
+
* client to only offer mobile-browse on those platforms.
|
|
575
|
+
*/
|
|
576
|
+
mobile_browse_platforms: ("ios" | "android")[] | null;
|
|
577
|
+
}
|
|
578
|
+
interface ExternalWalletsResponse {
|
|
579
|
+
data: ExternalWalletInfo[];
|
|
580
|
+
}
|
|
581
|
+
/**
|
|
582
|
+
* List the external (self-custody) wallets supported by the connect-wallet flow.
|
|
583
|
+
*
|
|
584
|
+
* Returns the wallet catalog (id, name, networks, install URL, icons, mobile
|
|
585
|
+
* in-app browser support) from the backend, so the supported set can change
|
|
586
|
+
* server-side without an SDK release.
|
|
587
|
+
*
|
|
588
|
+
* @param publishableKey - Optional publishable key, defaults to configured key
|
|
589
|
+
*/
|
|
590
|
+
declare function getExternalWallets(publishableKey?: string): Promise<ExternalWalletsResponse>;
|
|
591
|
+
/** A Unifold deposit address the hosted pay page can send funds to. */
|
|
592
|
+
interface WalletMobileDeepLinkDepositAddress {
|
|
593
|
+
chain_type: string;
|
|
594
|
+
address: string;
|
|
595
|
+
}
|
|
596
|
+
interface WalletMobileDeepLinkResponse {
|
|
597
|
+
/** The wallet the deep link was generated for. */
|
|
598
|
+
wallet: WalletMobileDeepLinkWallet;
|
|
599
|
+
/**
|
|
600
|
+
* Universal/deep link that opens the hosted Unifold pay page inside the
|
|
601
|
+
* wallet's in-app browser, or `null` when the wallet has no reliable
|
|
602
|
+
* dapp-browser deep link.
|
|
603
|
+
*/
|
|
604
|
+
deeplink: string | null;
|
|
605
|
+
/** The hosted Unifold pay URL the deep link points at (self-contained flow). */
|
|
606
|
+
pay_url: string;
|
|
607
|
+
/** Whether the wallet supports opening a dapp in its in-app browser. */
|
|
608
|
+
supported: boolean;
|
|
609
|
+
}
|
|
610
|
+
/**
|
|
611
|
+
* Generate a mobile in-app browser deep link for a wallet.
|
|
612
|
+
*
|
|
613
|
+
* Browser-extension wallets only inject their provider inside their own in-app
|
|
614
|
+
* browser, not in a regular mobile browser. The backend builds a self-contained
|
|
615
|
+
* Unifold-hosted pay URL (embedding the given deposit addresses) and wraps it in
|
|
616
|
+
* the selected wallet's in-app browser deep link (e.g. Phantom's embedded
|
|
617
|
+
* browser). Opening it runs the deposit flow inside the wallet without depending
|
|
618
|
+
* on the merchant's site. `deeplink` is `null` for wallets without a reliable
|
|
619
|
+
* dapp-browser deep link.
|
|
620
|
+
*
|
|
621
|
+
* @param wallet - Wallet id (phantom, metamask, coinbase, trust, rainbow, rabby, okx)
|
|
622
|
+
* @param depositAddresses - Unifold deposit addresses (one per source chain) to embed in the hosted pay URL
|
|
623
|
+
* @param publishableKey - Optional publishable key, defaults to configured key
|
|
624
|
+
*/
|
|
625
|
+
declare function getWalletMobileDeepLink(wallet: WalletMobileDeepLinkWallet, depositAddresses: WalletMobileDeepLinkDepositAddress[], publishableKey?: string): Promise<WalletMobileDeepLinkResponse>;
|
|
543
626
|
interface AddressBalanceResponse {
|
|
544
627
|
address: string;
|
|
545
628
|
chain_type: string;
|
|
@@ -1195,6 +1278,11 @@ declare function sendHypercoreTransaction(request: SendHypercoreTransactionReque
|
|
|
1195
1278
|
* formatStablecoinAmount("10000000", 6) // "10.00" (whole number)
|
|
1196
1279
|
*/
|
|
1197
1280
|
declare function formatStablecoinAmount(baseUnits: string, decimals: number): string;
|
|
1281
|
+
/**
|
|
1282
|
+
* Generate a KSUID-like ID without external dependencies.
|
|
1283
|
+
* Format: `base62(4-byte-timestamp + 16-random-bytes)` (27 chars).
|
|
1284
|
+
*/
|
|
1285
|
+
declare function generateKSUID(): string;
|
|
1198
1286
|
/**
|
|
1199
1287
|
* Generate a KSUID-like prefixed ID without external dependencies.
|
|
1200
1288
|
* Format: `{prefix}_{base62(4-byte-timestamp + 16-random-bytes)}` (27 chars after prefix).
|
|
@@ -1357,4 +1445,4 @@ declare const i18n: {
|
|
|
1357
1445
|
};
|
|
1358
1446
|
type I18nStrings = typeof i18n;
|
|
1359
1447
|
|
|
1360
|
-
export { ActionType, type AddressBalanceResponse, type AddressBalancesResponse, type AddressValidationFailureCode, type AddressValidationMetadata, type AuthenticateOAuthResult, 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 ConfirmIntegrationTransferResult, type CreateDepositAddressRequest, type CreateExchangeSessionRequest, type CreateExchangeSessionResponse, type CreateIntegrationTransferParams, type CreateIntegrationTransferResult, type DefaultTokenChain, type DefaultTokenMetadata, type DefaultTokenResponse, type DepositAddressResponse, type DepositEvent, DepositEventType, type DepositQuote, type DepositQuoteRequest, type DestinationToken, type DestinationTokenChain, type EvmContractCall, 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 IntegrationAccount, type IntegrationExchangeInfo, type IntegrationExchangesResponse, type IntegrationFeeAmount, type IntegrationHoldingsResponse, IntegrationProvider, 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, type RefreshIntegrationTokenResult, SOLANA_USDC_ADDRESS, type SendHypercoreTransactionRequest, type SendHypercoreTransactionResponse, type SendSolanaTransactionRequest, type SendSolanaTransactionResponse, type SourceToken, type SourceTokenNetwork, type StartIntegrationOAuthResult, 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 TransferDefaultTokenParams, type TransferDefaultTokenResult, type UserIpInfo, type VerifyAddressRequest, type VerifyAddressResponse, type Wallet, authenticateIntegrationOAuth, buildHypercoreTransaction, buildSolanaTransaction, checkHypercoreActivation, confirmIntegrationTransfer, createCashAppSession, createDepositAddress, createExchangeSession, createIntegrationTransfer, createOnrampSession, formatStablecoinAmount, generatePrefixedKSUID, getAddressBalance, getAddressBalances, getApiBaseUrl, getCashAppLimits, getCashAppSessionStatus, getChainName, getDefaultOnrampToken, getDepositAddress, getDepositQuote, getExchangeSessionStartUrl, getExchanges, getFiatCurrencies, getIconUrl, getIconUrlWithCdn, getIntegrationExchanges, getIntegrationHoldings, getIntegrationTransferDefaultToken, getIpAddress, getOnrampQuotes, getOnrampSessionStartUrl, getPreferredIconUrl, getProjectConfig, getSupportedDepositTokens, getSupportedDestinationTokens, getTokenChains, getTokenMetadata, getWalletByChainType, i18n, listPaymentIntentExecutions, pollDirectExecutions, queryExecutions, refreshIntegrationToken, retrievePaymentIntent, revokeIntegrationToken, sendHypercoreTransaction, sendSolanaTransaction, setApiConfig, startIntegrationOAuth, useUserIp, verifyRecipientAddress };
|
|
1448
|
+
export { ActionType, type AddressBalanceResponse, type AddressBalancesResponse, type AddressValidationFailureCode, type AddressValidationMetadata, type AuthenticateOAuthResult, 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 ConfirmIntegrationTransferResult, type CreateDepositAddressRequest, type CreateExchangeSessionRequest, type CreateExchangeSessionResponse, type CreateIntegrationTransferParams, type CreateIntegrationTransferResult, type DefaultTokenChain, type DefaultTokenMetadata, type DefaultTokenResponse, type DepositAddressResponse, type DepositEvent, DepositEventType, type DepositQuote, type DepositQuoteRequest, type DestinationToken, type DestinationTokenChain, type EvmContractCall, type ExchangeProviderInfo, type ExchangeProvidersResponse, type ExchangeSessionStartParams, type ExchangeWalletAddress, ExecutionStatus, type ExternalWalletChainType, type ExternalWalletInfo, type ExternalWalletsResponse, type FeaturedToken, type FeaturedWallet, type FiatCurrenciesResponse, type FiatCurrency, type GetExchangesQuery, type HypercoreActionType, type HypercoreActivationRequest, type HypercoreActivationResponse, type I18nStrings, type IconUrl, IneligibilityReason, type IntegrationAccount, type IntegrationExchangeInfo, type IntegrationExchangesResponse, type IntegrationFeeAmount, type IntegrationHoldingsResponse, IntegrationProvider, 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, type RefreshIntegrationTokenResult, SOLANA_USDC_ADDRESS, type SendHypercoreTransactionRequest, type SendHypercoreTransactionResponse, type SendSolanaTransactionRequest, type SendSolanaTransactionResponse, type SourceToken, type SourceTokenNetwork, type StartIntegrationOAuthResult, 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 TransferDefaultTokenParams, type TransferDefaultTokenResult, type UserIpInfo, type VerifyAddressRequest, type VerifyAddressResponse, type Wallet, type WalletMobileDeepLinkDepositAddress, type WalletMobileDeepLinkResponse, type WalletMobileDeepLinkWallet, authenticateIntegrationOAuth, buildHypercoreTransaction, buildSolanaTransaction, checkHypercoreActivation, confirmIntegrationTransfer, createCashAppSession, createDepositAddress, createExchangeSession, createIntegrationTransfer, createOnrampSession, formatStablecoinAmount, generateKSUID, generatePrefixedKSUID, getAddressBalance, getAddressBalances, getApiBaseUrl, getCashAppLimits, getCashAppSessionStatus, getChainName, getDefaultOnrampToken, getDepositAddress, getDepositQuote, getExchangeSessionStartUrl, getExchanges, getExternalWallets, getFiatCurrencies, getIconUrl, getIconUrlWithCdn, getIntegrationExchanges, getIntegrationHoldings, getIntegrationTransferDefaultToken, getIpAddress, getOnrampQuotes, getOnrampSessionStartUrl, getPreferredIconUrl, getProjectConfig, getSupportedDepositTokens, getSupportedDestinationTokens, getTokenChains, getTokenMetadata, getWalletByChainType, getWalletMobileDeepLink, i18n, listPaymentIntentExecutions, pollDirectExecutions, queryExecutions, refreshIntegrationToken, retrievePaymentIntent, revokeIntegrationToken, sendHypercoreTransaction, sendSolanaTransaction, setApiConfig, startIntegrationOAuth, useUserIp, verifyRecipientAddress };
|
package/dist/index.d.ts
CHANGED
|
@@ -457,9 +457,11 @@ interface ProjectConfigResponse {
|
|
|
457
457
|
project_name?: string;
|
|
458
458
|
asset_cdn_url: string;
|
|
459
459
|
transfer_crypto: {
|
|
460
|
+
enabled?: boolean;
|
|
460
461
|
networks: FeaturedToken[];
|
|
461
462
|
};
|
|
462
463
|
connect_wallet: {
|
|
464
|
+
enabled?: boolean;
|
|
463
465
|
wallets: FeaturedWallet[];
|
|
464
466
|
};
|
|
465
467
|
payment_networks: {
|
|
@@ -467,12 +469,21 @@ interface ProjectConfigResponse {
|
|
|
467
469
|
};
|
|
468
470
|
blocked_country_codes?: string[];
|
|
469
471
|
blocked_country_subdivisions?: BlockedCountrySubdivision[];
|
|
472
|
+
connect_exchange?: {
|
|
473
|
+
enabled: boolean;
|
|
474
|
+
};
|
|
475
|
+
cash_app?: {
|
|
476
|
+
enabled: boolean;
|
|
477
|
+
};
|
|
470
478
|
pay_with_exchange?: {
|
|
471
479
|
enabled: boolean;
|
|
472
480
|
};
|
|
473
481
|
fiat_onramp?: {
|
|
474
482
|
enabled: boolean;
|
|
475
483
|
};
|
|
484
|
+
deposit_tracker?: {
|
|
485
|
+
enabled: boolean;
|
|
486
|
+
};
|
|
476
487
|
hypercore_sponsorship?: {
|
|
477
488
|
enabled: boolean;
|
|
478
489
|
};
|
|
@@ -540,6 +551,78 @@ interface AddressBalancesResponse {
|
|
|
540
551
|
* @param publishableKey - Optional publishable key, defaults to configured key
|
|
541
552
|
*/
|
|
542
553
|
declare function getAddressBalances(address: string, chainType: ChainType, publishableKey?: string): Promise<AddressBalancesResponse>;
|
|
554
|
+
/** Wallet ids supported by the connect-wallet flow. */
|
|
555
|
+
type WalletMobileDeepLinkWallet = "phantom" | "metamask" | "coinbase" | "trust" | "rainbow" | "rabby" | "okx";
|
|
556
|
+
/** Chain types an external wallet can connect on. */
|
|
557
|
+
type ExternalWalletChainType = "ethereum" | "solana";
|
|
558
|
+
/** A supported external (self-custody) wallet from the directory endpoint. */
|
|
559
|
+
interface ExternalWalletInfo {
|
|
560
|
+
id: WalletMobileDeepLinkWallet;
|
|
561
|
+
name: string;
|
|
562
|
+
chain_types: ExternalWalletChainType[];
|
|
563
|
+
install_url: string;
|
|
564
|
+
icon_url: string;
|
|
565
|
+
icon_urls: Array<{
|
|
566
|
+
url: string;
|
|
567
|
+
format: "svg" | "png";
|
|
568
|
+
}>;
|
|
569
|
+
/** Whether the wallet can be opened into its in-app browser on mobile. */
|
|
570
|
+
supports_mobile_browse: boolean;
|
|
571
|
+
/**
|
|
572
|
+
* Mobile platforms the in-app browser deep link works on.
|
|
573
|
+
* `null` means all platforms; an explicit list (e.g. `["ios"]`) tells the
|
|
574
|
+
* client to only offer mobile-browse on those platforms.
|
|
575
|
+
*/
|
|
576
|
+
mobile_browse_platforms: ("ios" | "android")[] | null;
|
|
577
|
+
}
|
|
578
|
+
interface ExternalWalletsResponse {
|
|
579
|
+
data: ExternalWalletInfo[];
|
|
580
|
+
}
|
|
581
|
+
/**
|
|
582
|
+
* List the external (self-custody) wallets supported by the connect-wallet flow.
|
|
583
|
+
*
|
|
584
|
+
* Returns the wallet catalog (id, name, networks, install URL, icons, mobile
|
|
585
|
+
* in-app browser support) from the backend, so the supported set can change
|
|
586
|
+
* server-side without an SDK release.
|
|
587
|
+
*
|
|
588
|
+
* @param publishableKey - Optional publishable key, defaults to configured key
|
|
589
|
+
*/
|
|
590
|
+
declare function getExternalWallets(publishableKey?: string): Promise<ExternalWalletsResponse>;
|
|
591
|
+
/** A Unifold deposit address the hosted pay page can send funds to. */
|
|
592
|
+
interface WalletMobileDeepLinkDepositAddress {
|
|
593
|
+
chain_type: string;
|
|
594
|
+
address: string;
|
|
595
|
+
}
|
|
596
|
+
interface WalletMobileDeepLinkResponse {
|
|
597
|
+
/** The wallet the deep link was generated for. */
|
|
598
|
+
wallet: WalletMobileDeepLinkWallet;
|
|
599
|
+
/**
|
|
600
|
+
* Universal/deep link that opens the hosted Unifold pay page inside the
|
|
601
|
+
* wallet's in-app browser, or `null` when the wallet has no reliable
|
|
602
|
+
* dapp-browser deep link.
|
|
603
|
+
*/
|
|
604
|
+
deeplink: string | null;
|
|
605
|
+
/** The hosted Unifold pay URL the deep link points at (self-contained flow). */
|
|
606
|
+
pay_url: string;
|
|
607
|
+
/** Whether the wallet supports opening a dapp in its in-app browser. */
|
|
608
|
+
supported: boolean;
|
|
609
|
+
}
|
|
610
|
+
/**
|
|
611
|
+
* Generate a mobile in-app browser deep link for a wallet.
|
|
612
|
+
*
|
|
613
|
+
* Browser-extension wallets only inject their provider inside their own in-app
|
|
614
|
+
* browser, not in a regular mobile browser. The backend builds a self-contained
|
|
615
|
+
* Unifold-hosted pay URL (embedding the given deposit addresses) and wraps it in
|
|
616
|
+
* the selected wallet's in-app browser deep link (e.g. Phantom's embedded
|
|
617
|
+
* browser). Opening it runs the deposit flow inside the wallet without depending
|
|
618
|
+
* on the merchant's site. `deeplink` is `null` for wallets without a reliable
|
|
619
|
+
* dapp-browser deep link.
|
|
620
|
+
*
|
|
621
|
+
* @param wallet - Wallet id (phantom, metamask, coinbase, trust, rainbow, rabby, okx)
|
|
622
|
+
* @param depositAddresses - Unifold deposit addresses (one per source chain) to embed in the hosted pay URL
|
|
623
|
+
* @param publishableKey - Optional publishable key, defaults to configured key
|
|
624
|
+
*/
|
|
625
|
+
declare function getWalletMobileDeepLink(wallet: WalletMobileDeepLinkWallet, depositAddresses: WalletMobileDeepLinkDepositAddress[], publishableKey?: string): Promise<WalletMobileDeepLinkResponse>;
|
|
543
626
|
interface AddressBalanceResponse {
|
|
544
627
|
address: string;
|
|
545
628
|
chain_type: string;
|
|
@@ -1195,6 +1278,11 @@ declare function sendHypercoreTransaction(request: SendHypercoreTransactionReque
|
|
|
1195
1278
|
* formatStablecoinAmount("10000000", 6) // "10.00" (whole number)
|
|
1196
1279
|
*/
|
|
1197
1280
|
declare function formatStablecoinAmount(baseUnits: string, decimals: number): string;
|
|
1281
|
+
/**
|
|
1282
|
+
* Generate a KSUID-like ID without external dependencies.
|
|
1283
|
+
* Format: `base62(4-byte-timestamp + 16-random-bytes)` (27 chars).
|
|
1284
|
+
*/
|
|
1285
|
+
declare function generateKSUID(): string;
|
|
1198
1286
|
/**
|
|
1199
1287
|
* Generate a KSUID-like prefixed ID without external dependencies.
|
|
1200
1288
|
* Format: `{prefix}_{base62(4-byte-timestamp + 16-random-bytes)}` (27 chars after prefix).
|
|
@@ -1357,4 +1445,4 @@ declare const i18n: {
|
|
|
1357
1445
|
};
|
|
1358
1446
|
type I18nStrings = typeof i18n;
|
|
1359
1447
|
|
|
1360
|
-
export { ActionType, type AddressBalanceResponse, type AddressBalancesResponse, type AddressValidationFailureCode, type AddressValidationMetadata, type AuthenticateOAuthResult, 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 ConfirmIntegrationTransferResult, type CreateDepositAddressRequest, type CreateExchangeSessionRequest, type CreateExchangeSessionResponse, type CreateIntegrationTransferParams, type CreateIntegrationTransferResult, type DefaultTokenChain, type DefaultTokenMetadata, type DefaultTokenResponse, type DepositAddressResponse, type DepositEvent, DepositEventType, type DepositQuote, type DepositQuoteRequest, type DestinationToken, type DestinationTokenChain, type EvmContractCall, 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 IntegrationAccount, type IntegrationExchangeInfo, type IntegrationExchangesResponse, type IntegrationFeeAmount, type IntegrationHoldingsResponse, IntegrationProvider, 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, type RefreshIntegrationTokenResult, SOLANA_USDC_ADDRESS, type SendHypercoreTransactionRequest, type SendHypercoreTransactionResponse, type SendSolanaTransactionRequest, type SendSolanaTransactionResponse, type SourceToken, type SourceTokenNetwork, type StartIntegrationOAuthResult, 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 TransferDefaultTokenParams, type TransferDefaultTokenResult, type UserIpInfo, type VerifyAddressRequest, type VerifyAddressResponse, type Wallet, authenticateIntegrationOAuth, buildHypercoreTransaction, buildSolanaTransaction, checkHypercoreActivation, confirmIntegrationTransfer, createCashAppSession, createDepositAddress, createExchangeSession, createIntegrationTransfer, createOnrampSession, formatStablecoinAmount, generatePrefixedKSUID, getAddressBalance, getAddressBalances, getApiBaseUrl, getCashAppLimits, getCashAppSessionStatus, getChainName, getDefaultOnrampToken, getDepositAddress, getDepositQuote, getExchangeSessionStartUrl, getExchanges, getFiatCurrencies, getIconUrl, getIconUrlWithCdn, getIntegrationExchanges, getIntegrationHoldings, getIntegrationTransferDefaultToken, getIpAddress, getOnrampQuotes, getOnrampSessionStartUrl, getPreferredIconUrl, getProjectConfig, getSupportedDepositTokens, getSupportedDestinationTokens, getTokenChains, getTokenMetadata, getWalletByChainType, i18n, listPaymentIntentExecutions, pollDirectExecutions, queryExecutions, refreshIntegrationToken, retrievePaymentIntent, revokeIntegrationToken, sendHypercoreTransaction, sendSolanaTransaction, setApiConfig, startIntegrationOAuth, useUserIp, verifyRecipientAddress };
|
|
1448
|
+
export { ActionType, type AddressBalanceResponse, type AddressBalancesResponse, type AddressValidationFailureCode, type AddressValidationMetadata, type AuthenticateOAuthResult, 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 ConfirmIntegrationTransferResult, type CreateDepositAddressRequest, type CreateExchangeSessionRequest, type CreateExchangeSessionResponse, type CreateIntegrationTransferParams, type CreateIntegrationTransferResult, type DefaultTokenChain, type DefaultTokenMetadata, type DefaultTokenResponse, type DepositAddressResponse, type DepositEvent, DepositEventType, type DepositQuote, type DepositQuoteRequest, type DestinationToken, type DestinationTokenChain, type EvmContractCall, type ExchangeProviderInfo, type ExchangeProvidersResponse, type ExchangeSessionStartParams, type ExchangeWalletAddress, ExecutionStatus, type ExternalWalletChainType, type ExternalWalletInfo, type ExternalWalletsResponse, type FeaturedToken, type FeaturedWallet, type FiatCurrenciesResponse, type FiatCurrency, type GetExchangesQuery, type HypercoreActionType, type HypercoreActivationRequest, type HypercoreActivationResponse, type I18nStrings, type IconUrl, IneligibilityReason, type IntegrationAccount, type IntegrationExchangeInfo, type IntegrationExchangesResponse, type IntegrationFeeAmount, type IntegrationHoldingsResponse, IntegrationProvider, 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, type RefreshIntegrationTokenResult, SOLANA_USDC_ADDRESS, type SendHypercoreTransactionRequest, type SendHypercoreTransactionResponse, type SendSolanaTransactionRequest, type SendSolanaTransactionResponse, type SourceToken, type SourceTokenNetwork, type StartIntegrationOAuthResult, 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 TransferDefaultTokenParams, type TransferDefaultTokenResult, type UserIpInfo, type VerifyAddressRequest, type VerifyAddressResponse, type Wallet, type WalletMobileDeepLinkDepositAddress, type WalletMobileDeepLinkResponse, type WalletMobileDeepLinkWallet, authenticateIntegrationOAuth, buildHypercoreTransaction, buildSolanaTransaction, checkHypercoreActivation, confirmIntegrationTransfer, createCashAppSession, createDepositAddress, createExchangeSession, createIntegrationTransfer, createOnrampSession, formatStablecoinAmount, generateKSUID, generatePrefixedKSUID, getAddressBalance, getAddressBalances, getApiBaseUrl, getCashAppLimits, getCashAppSessionStatus, getChainName, getDefaultOnrampToken, getDepositAddress, getDepositQuote, getExchangeSessionStartUrl, getExchanges, getExternalWallets, getFiatCurrencies, getIconUrl, getIconUrlWithCdn, getIntegrationExchanges, getIntegrationHoldings, getIntegrationTransferDefaultToken, getIpAddress, getOnrampQuotes, getOnrampSessionStartUrl, getPreferredIconUrl, getProjectConfig, getSupportedDepositTokens, getSupportedDestinationTokens, getTokenChains, getTokenMetadata, getWalletByChainType, getWalletMobileDeepLink, i18n, listPaymentIntentExecutions, pollDirectExecutions, queryExecutions, refreshIntegrationToken, retrievePaymentIntent, revokeIntegrationToken, sendHypercoreTransaction, sendSolanaTransaction, setApiConfig, startIntegrationOAuth, useUserIp, verifyRecipientAddress };
|
package/dist/index.js
CHANGED
|
@@ -37,6 +37,7 @@ __export(index_exports, {
|
|
|
37
37
|
createIntegrationTransfer: () => createIntegrationTransfer,
|
|
38
38
|
createOnrampSession: () => createOnrampSession,
|
|
39
39
|
formatStablecoinAmount: () => formatStablecoinAmount,
|
|
40
|
+
generateKSUID: () => generateKSUID,
|
|
40
41
|
generatePrefixedKSUID: () => generatePrefixedKSUID,
|
|
41
42
|
getAddressBalance: () => getAddressBalance,
|
|
42
43
|
getAddressBalances: () => getAddressBalances,
|
|
@@ -49,6 +50,7 @@ __export(index_exports, {
|
|
|
49
50
|
getDepositQuote: () => getDepositQuote,
|
|
50
51
|
getExchangeSessionStartUrl: () => getExchangeSessionStartUrl,
|
|
51
52
|
getExchanges: () => getExchanges,
|
|
53
|
+
getExternalWallets: () => getExternalWallets,
|
|
52
54
|
getFiatCurrencies: () => getFiatCurrencies,
|
|
53
55
|
getIconUrl: () => getIconUrl,
|
|
54
56
|
getIconUrlWithCdn: () => getIconUrlWithCdn,
|
|
@@ -65,6 +67,7 @@ __export(index_exports, {
|
|
|
65
67
|
getTokenChains: () => getTokenChains,
|
|
66
68
|
getTokenMetadata: () => getTokenMetadata,
|
|
67
69
|
getWalletByChainType: () => getWalletByChainType,
|
|
70
|
+
getWalletMobileDeepLink: () => getWalletMobileDeepLink,
|
|
68
71
|
i18n: () => i18n,
|
|
69
72
|
listPaymentIntentExecutions: () => listPaymentIntentExecutions,
|
|
70
73
|
pollDirectExecutions: () => pollDirectExecutions,
|
|
@@ -81,6 +84,44 @@ __export(index_exports, {
|
|
|
81
84
|
});
|
|
82
85
|
module.exports = __toCommonJS(index_exports);
|
|
83
86
|
|
|
87
|
+
// src/lib/utils.ts
|
|
88
|
+
function formatStablecoinAmount(baseUnits, decimals) {
|
|
89
|
+
const raw = Number(baseUnits) / 10 ** decimals;
|
|
90
|
+
const floored = Math.floor(raw * 100) / 100;
|
|
91
|
+
const ceiled = raw > floored ? floored + 0.01 : raw;
|
|
92
|
+
return ceiled.toFixed(2);
|
|
93
|
+
}
|
|
94
|
+
function generateKSUID() {
|
|
95
|
+
const BASE62 = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
|
|
96
|
+
const KSUID_EPOCH = 14e8;
|
|
97
|
+
const timestampSeconds = Math.floor(Date.now() / 1e3) - KSUID_EPOCH;
|
|
98
|
+
const payload = new Uint8Array(20);
|
|
99
|
+
payload[0] = timestampSeconds >>> 24 & 255;
|
|
100
|
+
payload[1] = timestampSeconds >>> 16 & 255;
|
|
101
|
+
payload[2] = timestampSeconds >>> 8 & 255;
|
|
102
|
+
payload[3] = timestampSeconds & 255;
|
|
103
|
+
if (typeof crypto !== "undefined" && crypto.getRandomValues) {
|
|
104
|
+
crypto.getRandomValues(payload.subarray(4));
|
|
105
|
+
} else {
|
|
106
|
+
for (let i = 4; i < 20; i++) {
|
|
107
|
+
payload[i] = Math.floor(Math.random() * 256);
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
let value = 0n;
|
|
111
|
+
for (const byte of payload) {
|
|
112
|
+
value = value << 8n | BigInt(byte);
|
|
113
|
+
}
|
|
114
|
+
let encoded = "";
|
|
115
|
+
while (value > 0n) {
|
|
116
|
+
encoded = BASE62[Number(value % 62n)] + encoded;
|
|
117
|
+
value = value / 62n;
|
|
118
|
+
}
|
|
119
|
+
return encoded.padStart(27, "0");
|
|
120
|
+
}
|
|
121
|
+
function generatePrefixedKSUID(prefix) {
|
|
122
|
+
return `${prefix}_${generateKSUID()}`;
|
|
123
|
+
}
|
|
124
|
+
|
|
84
125
|
// src/lib/api.ts
|
|
85
126
|
var API_BASE_URL = (() => {
|
|
86
127
|
try {
|
|
@@ -408,9 +449,7 @@ function getOnrampSessionStartUrl(request, publishableKey) {
|
|
|
408
449
|
if (request.subdivision_code) {
|
|
409
450
|
params.append("subdivision_code", request.subdivision_code);
|
|
410
451
|
}
|
|
411
|
-
|
|
412
|
-
params.append("external_id", request.external_id);
|
|
413
|
-
}
|
|
452
|
+
params.append("external_id", request.external_id ?? generatePrefixedKSUID("ors"));
|
|
414
453
|
if (request.email) {
|
|
415
454
|
params.append("email", request.email);
|
|
416
455
|
}
|
|
@@ -521,6 +560,40 @@ async function getAddressBalances(address, chainType, publishableKey) {
|
|
|
521
560
|
const data = await response.json();
|
|
522
561
|
return data;
|
|
523
562
|
}
|
|
563
|
+
async function getExternalWallets(publishableKey) {
|
|
564
|
+
const pk = publishableKey || DEFAULT_PUBLISHABLE_KEY;
|
|
565
|
+
validatePublishableKey(pk);
|
|
566
|
+
const response = await fetch(`${API_BASE_URL}/v1/public/external_wallets`, {
|
|
567
|
+
method: "GET",
|
|
568
|
+
headers: {
|
|
569
|
+
accept: "application/json",
|
|
570
|
+
"x-publishable-key": pk
|
|
571
|
+
}
|
|
572
|
+
});
|
|
573
|
+
if (!response.ok) {
|
|
574
|
+
throw new Error(`Failed to fetch external wallets: ${response.statusText}`);
|
|
575
|
+
}
|
|
576
|
+
const data = await response.json();
|
|
577
|
+
return data;
|
|
578
|
+
}
|
|
579
|
+
async function getWalletMobileDeepLink(wallet, depositAddresses, publishableKey) {
|
|
580
|
+
const pk = publishableKey || DEFAULT_PUBLISHABLE_KEY;
|
|
581
|
+
validatePublishableKey(pk);
|
|
582
|
+
const response = await fetch(`${API_BASE_URL}/v1/public/external_wallets/mobile_deeplink`, {
|
|
583
|
+
method: "POST",
|
|
584
|
+
headers: {
|
|
585
|
+
"Content-Type": "application/json",
|
|
586
|
+
accept: "application/json",
|
|
587
|
+
"x-publishable-key": pk
|
|
588
|
+
},
|
|
589
|
+
body: JSON.stringify({ wallet, deposit_addresses: depositAddresses })
|
|
590
|
+
});
|
|
591
|
+
if (!response.ok) {
|
|
592
|
+
throw new Error(`Failed to generate wallet deep link: ${response.statusText}`);
|
|
593
|
+
}
|
|
594
|
+
const data = await response.json();
|
|
595
|
+
return data;
|
|
596
|
+
}
|
|
524
597
|
async function getAddressBalance(address, chainType, chainId, tokenAddress, publishableKey) {
|
|
525
598
|
const pk = publishableKey || DEFAULT_PUBLISHABLE_KEY;
|
|
526
599
|
validatePublishableKey(pk);
|
|
@@ -645,9 +718,7 @@ function getExchangeSessionStartUrl(request, publishableKey) {
|
|
|
645
718
|
if (request.source_amount) {
|
|
646
719
|
params.append("source_amount", request.source_amount);
|
|
647
720
|
}
|
|
648
|
-
|
|
649
|
-
params.append("external_id", request.external_id);
|
|
650
|
-
}
|
|
721
|
+
params.append("external_id", request.external_id ?? generatePrefixedKSUID("exc"));
|
|
651
722
|
return `${API_BASE_URL}/v1/public/onramps/exchanges/sessions/start?${params.toString()}`;
|
|
652
723
|
}
|
|
653
724
|
async function getIntegrationExchanges(publishableKey) {
|
|
@@ -1028,42 +1099,6 @@ async function sendHypercoreTransaction(request, publishableKey) {
|
|
|
1028
1099
|
return response.json();
|
|
1029
1100
|
}
|
|
1030
1101
|
|
|
1031
|
-
// src/lib/utils.ts
|
|
1032
|
-
function formatStablecoinAmount(baseUnits, decimals) {
|
|
1033
|
-
const raw = Number(baseUnits) / 10 ** decimals;
|
|
1034
|
-
const floored = Math.floor(raw * 100) / 100;
|
|
1035
|
-
const ceiled = raw > floored ? floored + 0.01 : raw;
|
|
1036
|
-
return ceiled.toFixed(2);
|
|
1037
|
-
}
|
|
1038
|
-
function generatePrefixedKSUID(prefix) {
|
|
1039
|
-
const BASE62 = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
|
|
1040
|
-
const KSUID_EPOCH = 14e8;
|
|
1041
|
-
const timestampSeconds = Math.floor(Date.now() / 1e3) - KSUID_EPOCH;
|
|
1042
|
-
const payload = new Uint8Array(20);
|
|
1043
|
-
payload[0] = timestampSeconds >>> 24 & 255;
|
|
1044
|
-
payload[1] = timestampSeconds >>> 16 & 255;
|
|
1045
|
-
payload[2] = timestampSeconds >>> 8 & 255;
|
|
1046
|
-
payload[3] = timestampSeconds & 255;
|
|
1047
|
-
if (typeof crypto !== "undefined" && crypto.getRandomValues) {
|
|
1048
|
-
crypto.getRandomValues(payload.subarray(4));
|
|
1049
|
-
} else {
|
|
1050
|
-
for (let i = 4; i < 20; i++) {
|
|
1051
|
-
payload[i] = Math.floor(Math.random() * 256);
|
|
1052
|
-
}
|
|
1053
|
-
}
|
|
1054
|
-
let value = 0n;
|
|
1055
|
-
for (const byte of payload) {
|
|
1056
|
-
value = value << 8n | BigInt(byte);
|
|
1057
|
-
}
|
|
1058
|
-
let encoded = "";
|
|
1059
|
-
while (value > 0n) {
|
|
1060
|
-
encoded = BASE62[Number(value % 62n)] + encoded;
|
|
1061
|
-
value = value / 62n;
|
|
1062
|
-
}
|
|
1063
|
-
encoded = encoded.padStart(27, "0");
|
|
1064
|
-
return `${prefix}_${encoded}`;
|
|
1065
|
-
}
|
|
1066
|
-
|
|
1067
1102
|
// src/lib/events.ts
|
|
1068
1103
|
var DepositEventType = /* @__PURE__ */ ((DepositEventType2) => {
|
|
1069
1104
|
DepositEventType2["ONRAMP_SESSION_CREATED"] = "onramp_session.created";
|
|
@@ -1220,6 +1255,7 @@ var i18n = en_default;
|
|
|
1220
1255
|
createIntegrationTransfer,
|
|
1221
1256
|
createOnrampSession,
|
|
1222
1257
|
formatStablecoinAmount,
|
|
1258
|
+
generateKSUID,
|
|
1223
1259
|
generatePrefixedKSUID,
|
|
1224
1260
|
getAddressBalance,
|
|
1225
1261
|
getAddressBalances,
|
|
@@ -1232,6 +1268,7 @@ var i18n = en_default;
|
|
|
1232
1268
|
getDepositQuote,
|
|
1233
1269
|
getExchangeSessionStartUrl,
|
|
1234
1270
|
getExchanges,
|
|
1271
|
+
getExternalWallets,
|
|
1235
1272
|
getFiatCurrencies,
|
|
1236
1273
|
getIconUrl,
|
|
1237
1274
|
getIconUrlWithCdn,
|
|
@@ -1248,6 +1285,7 @@ var i18n = en_default;
|
|
|
1248
1285
|
getTokenChains,
|
|
1249
1286
|
getTokenMetadata,
|
|
1250
1287
|
getWalletByChainType,
|
|
1288
|
+
getWalletMobileDeepLink,
|
|
1251
1289
|
i18n,
|
|
1252
1290
|
listPaymentIntentExecutions,
|
|
1253
1291
|
pollDirectExecutions,
|
package/dist/index.mjs
CHANGED
|
@@ -1,3 +1,41 @@
|
|
|
1
|
+
// src/lib/utils.ts
|
|
2
|
+
function formatStablecoinAmount(baseUnits, decimals) {
|
|
3
|
+
const raw = Number(baseUnits) / 10 ** decimals;
|
|
4
|
+
const floored = Math.floor(raw * 100) / 100;
|
|
5
|
+
const ceiled = raw > floored ? floored + 0.01 : raw;
|
|
6
|
+
return ceiled.toFixed(2);
|
|
7
|
+
}
|
|
8
|
+
function generateKSUID() {
|
|
9
|
+
const BASE62 = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
|
|
10
|
+
const KSUID_EPOCH = 14e8;
|
|
11
|
+
const timestampSeconds = Math.floor(Date.now() / 1e3) - KSUID_EPOCH;
|
|
12
|
+
const payload = new Uint8Array(20);
|
|
13
|
+
payload[0] = timestampSeconds >>> 24 & 255;
|
|
14
|
+
payload[1] = timestampSeconds >>> 16 & 255;
|
|
15
|
+
payload[2] = timestampSeconds >>> 8 & 255;
|
|
16
|
+
payload[3] = timestampSeconds & 255;
|
|
17
|
+
if (typeof crypto !== "undefined" && crypto.getRandomValues) {
|
|
18
|
+
crypto.getRandomValues(payload.subarray(4));
|
|
19
|
+
} else {
|
|
20
|
+
for (let i = 4; i < 20; i++) {
|
|
21
|
+
payload[i] = Math.floor(Math.random() * 256);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
let value = 0n;
|
|
25
|
+
for (const byte of payload) {
|
|
26
|
+
value = value << 8n | BigInt(byte);
|
|
27
|
+
}
|
|
28
|
+
let encoded = "";
|
|
29
|
+
while (value > 0n) {
|
|
30
|
+
encoded = BASE62[Number(value % 62n)] + encoded;
|
|
31
|
+
value = value / 62n;
|
|
32
|
+
}
|
|
33
|
+
return encoded.padStart(27, "0");
|
|
34
|
+
}
|
|
35
|
+
function generatePrefixedKSUID(prefix) {
|
|
36
|
+
return `${prefix}_${generateKSUID()}`;
|
|
37
|
+
}
|
|
38
|
+
|
|
1
39
|
// src/lib/api.ts
|
|
2
40
|
var API_BASE_URL = (() => {
|
|
3
41
|
try {
|
|
@@ -325,9 +363,7 @@ function getOnrampSessionStartUrl(request, publishableKey) {
|
|
|
325
363
|
if (request.subdivision_code) {
|
|
326
364
|
params.append("subdivision_code", request.subdivision_code);
|
|
327
365
|
}
|
|
328
|
-
|
|
329
|
-
params.append("external_id", request.external_id);
|
|
330
|
-
}
|
|
366
|
+
params.append("external_id", request.external_id ?? generatePrefixedKSUID("ors"));
|
|
331
367
|
if (request.email) {
|
|
332
368
|
params.append("email", request.email);
|
|
333
369
|
}
|
|
@@ -438,6 +474,40 @@ async function getAddressBalances(address, chainType, publishableKey) {
|
|
|
438
474
|
const data = await response.json();
|
|
439
475
|
return data;
|
|
440
476
|
}
|
|
477
|
+
async function getExternalWallets(publishableKey) {
|
|
478
|
+
const pk = publishableKey || DEFAULT_PUBLISHABLE_KEY;
|
|
479
|
+
validatePublishableKey(pk);
|
|
480
|
+
const response = await fetch(`${API_BASE_URL}/v1/public/external_wallets`, {
|
|
481
|
+
method: "GET",
|
|
482
|
+
headers: {
|
|
483
|
+
accept: "application/json",
|
|
484
|
+
"x-publishable-key": pk
|
|
485
|
+
}
|
|
486
|
+
});
|
|
487
|
+
if (!response.ok) {
|
|
488
|
+
throw new Error(`Failed to fetch external wallets: ${response.statusText}`);
|
|
489
|
+
}
|
|
490
|
+
const data = await response.json();
|
|
491
|
+
return data;
|
|
492
|
+
}
|
|
493
|
+
async function getWalletMobileDeepLink(wallet, depositAddresses, publishableKey) {
|
|
494
|
+
const pk = publishableKey || DEFAULT_PUBLISHABLE_KEY;
|
|
495
|
+
validatePublishableKey(pk);
|
|
496
|
+
const response = await fetch(`${API_BASE_URL}/v1/public/external_wallets/mobile_deeplink`, {
|
|
497
|
+
method: "POST",
|
|
498
|
+
headers: {
|
|
499
|
+
"Content-Type": "application/json",
|
|
500
|
+
accept: "application/json",
|
|
501
|
+
"x-publishable-key": pk
|
|
502
|
+
},
|
|
503
|
+
body: JSON.stringify({ wallet, deposit_addresses: depositAddresses })
|
|
504
|
+
});
|
|
505
|
+
if (!response.ok) {
|
|
506
|
+
throw new Error(`Failed to generate wallet deep link: ${response.statusText}`);
|
|
507
|
+
}
|
|
508
|
+
const data = await response.json();
|
|
509
|
+
return data;
|
|
510
|
+
}
|
|
441
511
|
async function getAddressBalance(address, chainType, chainId, tokenAddress, publishableKey) {
|
|
442
512
|
const pk = publishableKey || DEFAULT_PUBLISHABLE_KEY;
|
|
443
513
|
validatePublishableKey(pk);
|
|
@@ -562,9 +632,7 @@ function getExchangeSessionStartUrl(request, publishableKey) {
|
|
|
562
632
|
if (request.source_amount) {
|
|
563
633
|
params.append("source_amount", request.source_amount);
|
|
564
634
|
}
|
|
565
|
-
|
|
566
|
-
params.append("external_id", request.external_id);
|
|
567
|
-
}
|
|
635
|
+
params.append("external_id", request.external_id ?? generatePrefixedKSUID("exc"));
|
|
568
636
|
return `${API_BASE_URL}/v1/public/onramps/exchanges/sessions/start?${params.toString()}`;
|
|
569
637
|
}
|
|
570
638
|
async function getIntegrationExchanges(publishableKey) {
|
|
@@ -945,42 +1013,6 @@ async function sendHypercoreTransaction(request, publishableKey) {
|
|
|
945
1013
|
return response.json();
|
|
946
1014
|
}
|
|
947
1015
|
|
|
948
|
-
// src/lib/utils.ts
|
|
949
|
-
function formatStablecoinAmount(baseUnits, decimals) {
|
|
950
|
-
const raw = Number(baseUnits) / 10 ** decimals;
|
|
951
|
-
const floored = Math.floor(raw * 100) / 100;
|
|
952
|
-
const ceiled = raw > floored ? floored + 0.01 : raw;
|
|
953
|
-
return ceiled.toFixed(2);
|
|
954
|
-
}
|
|
955
|
-
function generatePrefixedKSUID(prefix) {
|
|
956
|
-
const BASE62 = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
|
|
957
|
-
const KSUID_EPOCH = 14e8;
|
|
958
|
-
const timestampSeconds = Math.floor(Date.now() / 1e3) - KSUID_EPOCH;
|
|
959
|
-
const payload = new Uint8Array(20);
|
|
960
|
-
payload[0] = timestampSeconds >>> 24 & 255;
|
|
961
|
-
payload[1] = timestampSeconds >>> 16 & 255;
|
|
962
|
-
payload[2] = timestampSeconds >>> 8 & 255;
|
|
963
|
-
payload[3] = timestampSeconds & 255;
|
|
964
|
-
if (typeof crypto !== "undefined" && crypto.getRandomValues) {
|
|
965
|
-
crypto.getRandomValues(payload.subarray(4));
|
|
966
|
-
} else {
|
|
967
|
-
for (let i = 4; i < 20; i++) {
|
|
968
|
-
payload[i] = Math.floor(Math.random() * 256);
|
|
969
|
-
}
|
|
970
|
-
}
|
|
971
|
-
let value = 0n;
|
|
972
|
-
for (const byte of payload) {
|
|
973
|
-
value = value << 8n | BigInt(byte);
|
|
974
|
-
}
|
|
975
|
-
let encoded = "";
|
|
976
|
-
while (value > 0n) {
|
|
977
|
-
encoded = BASE62[Number(value % 62n)] + encoded;
|
|
978
|
-
value = value / 62n;
|
|
979
|
-
}
|
|
980
|
-
encoded = encoded.padStart(27, "0");
|
|
981
|
-
return `${prefix}_${encoded}`;
|
|
982
|
-
}
|
|
983
|
-
|
|
984
1016
|
// src/lib/events.ts
|
|
985
1017
|
var DepositEventType = /* @__PURE__ */ ((DepositEventType2) => {
|
|
986
1018
|
DepositEventType2["ONRAMP_SESSION_CREATED"] = "onramp_session.created";
|
|
@@ -1136,6 +1168,7 @@ export {
|
|
|
1136
1168
|
createIntegrationTransfer,
|
|
1137
1169
|
createOnrampSession,
|
|
1138
1170
|
formatStablecoinAmount,
|
|
1171
|
+
generateKSUID,
|
|
1139
1172
|
generatePrefixedKSUID,
|
|
1140
1173
|
getAddressBalance,
|
|
1141
1174
|
getAddressBalances,
|
|
@@ -1148,6 +1181,7 @@ export {
|
|
|
1148
1181
|
getDepositQuote,
|
|
1149
1182
|
getExchangeSessionStartUrl,
|
|
1150
1183
|
getExchanges,
|
|
1184
|
+
getExternalWallets,
|
|
1151
1185
|
getFiatCurrencies,
|
|
1152
1186
|
getIconUrl,
|
|
1153
1187
|
getIconUrlWithCdn,
|
|
@@ -1164,6 +1198,7 @@ export {
|
|
|
1164
1198
|
getTokenChains,
|
|
1165
1199
|
getTokenMetadata,
|
|
1166
1200
|
getWalletByChainType,
|
|
1201
|
+
getWalletMobileDeepLink,
|
|
1167
1202
|
i18n,
|
|
1168
1203
|
listPaymentIntentExecutions,
|
|
1169
1204
|
pollDirectExecutions,
|