@unifold/core 0.1.41 → 0.1.43
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 +169 -4
- package/dist/index.d.ts +169 -4
- package/dist/index.js +185 -4
- package/dist/index.mjs +178 -4
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -36,12 +36,18 @@ interface Wallet {
|
|
|
36
36
|
interface DepositAddressResponse {
|
|
37
37
|
data: Wallet[];
|
|
38
38
|
}
|
|
39
|
+
declare enum ActionType {
|
|
40
|
+
Deposit = "deposit",
|
|
41
|
+
Withdraw = "withdraw"
|
|
42
|
+
}
|
|
39
43
|
interface CreateDepositAddressRequest {
|
|
40
44
|
external_user_id: string;
|
|
41
45
|
destination_chain_type: string;
|
|
42
46
|
destination_chain_id: string;
|
|
43
47
|
destination_token_address: string;
|
|
44
48
|
recipient_address: string;
|
|
49
|
+
/** @default ActionType.Deposit */
|
|
50
|
+
action_type?: ActionType;
|
|
45
51
|
client_metadata?: Record<string, unknown>;
|
|
46
52
|
}
|
|
47
53
|
/**
|
|
@@ -116,6 +122,7 @@ interface AutoSwapResponse {
|
|
|
116
122
|
declare const SOLANA_USDC_ADDRESS = "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v";
|
|
117
123
|
interface QueryExecutionsRequest {
|
|
118
124
|
external_user_id: string;
|
|
125
|
+
action_type?: ActionType;
|
|
119
126
|
}
|
|
120
127
|
interface QueryExecutionsResponse {
|
|
121
128
|
data: AutoSwapResponse[];
|
|
@@ -123,12 +130,12 @@ interface QueryExecutionsResponse {
|
|
|
123
130
|
has_more: boolean;
|
|
124
131
|
}
|
|
125
132
|
/**
|
|
126
|
-
* Query
|
|
127
|
-
* Returns ALL executions - filter client-side for new ones
|
|
133
|
+
* Query direct executions for a user, optionally filtered by action type.
|
|
128
134
|
* @param externalUserId - External user ID
|
|
129
135
|
* @param publishableKey - Optional publishable key, defaults to configured key
|
|
136
|
+
* @param actionType - Optional filter: ActionType.Deposit or ActionType.Withdraw
|
|
130
137
|
*/
|
|
131
|
-
declare function queryExecutions(externalUserId: string, publishableKey?: string): Promise<QueryExecutionsResponse>;
|
|
138
|
+
declare function queryExecutions(externalUserId: string, publishableKey?: string, actionType?: ActionType): Promise<QueryExecutionsResponse>;
|
|
132
139
|
interface PollExecutionsRequest {
|
|
133
140
|
deposit_wallet_id: string;
|
|
134
141
|
}
|
|
@@ -155,6 +162,30 @@ interface SupportedChain {
|
|
|
155
162
|
estimated_processing_time: number | null;
|
|
156
163
|
minimum_deposit_amount_usd: number;
|
|
157
164
|
}
|
|
165
|
+
interface DestinationTokenChain {
|
|
166
|
+
chain_id: string;
|
|
167
|
+
chain_name: string;
|
|
168
|
+
chain_type: string;
|
|
169
|
+
token_address: string;
|
|
170
|
+
decimals: number;
|
|
171
|
+
icon_url: string;
|
|
172
|
+
icon_urls?: IconUrl[];
|
|
173
|
+
}
|
|
174
|
+
interface DestinationToken {
|
|
175
|
+
symbol: string;
|
|
176
|
+
name: string;
|
|
177
|
+
icon_url: string;
|
|
178
|
+
icon_urls?: IconUrl[];
|
|
179
|
+
chains: DestinationTokenChain[];
|
|
180
|
+
}
|
|
181
|
+
interface SupportedDestinationTokensResponse {
|
|
182
|
+
data: DestinationToken[];
|
|
183
|
+
}
|
|
184
|
+
/**
|
|
185
|
+
* Get supported destination tokens (used for withdraw flow)
|
|
186
|
+
* @param publishableKey - Optional publishable key, defaults to configured key
|
|
187
|
+
*/
|
|
188
|
+
declare function getSupportedDestinationTokens(publishableKey?: string): Promise<SupportedDestinationTokensResponse>;
|
|
158
189
|
interface SupportedToken {
|
|
159
190
|
symbol: string;
|
|
160
191
|
name: string;
|
|
@@ -600,6 +631,114 @@ interface SendSolanaTransactionResponse {
|
|
|
600
631
|
* @returns Transaction signature (hash) that can be used to track the transaction
|
|
601
632
|
*/
|
|
602
633
|
declare function sendSolanaTransaction(request: SendSolanaTransactionRequest, publishableKey?: string): Promise<SendSolanaTransactionResponse>;
|
|
634
|
+
interface PaymentIntentDepositAddress {
|
|
635
|
+
id: string;
|
|
636
|
+
chain_type: ChainType;
|
|
637
|
+
address_type: string | null;
|
|
638
|
+
address: string;
|
|
639
|
+
}
|
|
640
|
+
interface PaymentIntent {
|
|
641
|
+
id: string;
|
|
642
|
+
user_id: string | null;
|
|
643
|
+
amount: string;
|
|
644
|
+
amount_usd: string;
|
|
645
|
+
amount_received: string;
|
|
646
|
+
amount_received_usd: string;
|
|
647
|
+
currency: string;
|
|
648
|
+
status: string;
|
|
649
|
+
client_secret: string;
|
|
650
|
+
destination_network: string | null;
|
|
651
|
+
destination_chain_type: ChainType;
|
|
652
|
+
destination_chain_id: string;
|
|
653
|
+
destination_token_address: string;
|
|
654
|
+
recipient_address: string;
|
|
655
|
+
destination_token_decimals: number;
|
|
656
|
+
deposit_addresses: PaymentIntentDepositAddress[];
|
|
657
|
+
metadata: Record<string, string> | null;
|
|
658
|
+
description: string | null;
|
|
659
|
+
livemode: boolean;
|
|
660
|
+
settlement_tolerance_percent: number;
|
|
661
|
+
canceled_at: string | null;
|
|
662
|
+
cancellation_reason: string | null;
|
|
663
|
+
expires_at: string | null;
|
|
664
|
+
created_at: string;
|
|
665
|
+
updated_at: string;
|
|
666
|
+
}
|
|
667
|
+
/**
|
|
668
|
+
* Retrieve a payment intent by its client secret.
|
|
669
|
+
* Uses the public endpoint that requires a publishable key header.
|
|
670
|
+
*/
|
|
671
|
+
declare function retrievePaymentIntent(clientSecret: string, publishableKey?: string): Promise<PaymentIntent>;
|
|
672
|
+
interface PaymentIntentExecutionsResponse {
|
|
673
|
+
data: AutoSwapResponse[];
|
|
674
|
+
}
|
|
675
|
+
/**
|
|
676
|
+
* List all executions (deposits/swaps) for a payment intent.
|
|
677
|
+
* Authenticates via client_secret and publishable key.
|
|
678
|
+
*/
|
|
679
|
+
declare function listPaymentIntentExecutions(clientSecret: string, publishableKey?: string): Promise<PaymentIntentExecutionsResponse>;
|
|
680
|
+
interface DepositQuoteRequest {
|
|
681
|
+
source_chain_type: string;
|
|
682
|
+
source_chain_id: string;
|
|
683
|
+
source_token_address: string;
|
|
684
|
+
destination_amount: string;
|
|
685
|
+
destination_chain_type: string;
|
|
686
|
+
destination_chain_id: string;
|
|
687
|
+
destination_token_address: string;
|
|
688
|
+
}
|
|
689
|
+
interface DepositQuote {
|
|
690
|
+
source_amount: string;
|
|
691
|
+
source_amount_usd: string | null;
|
|
692
|
+
source_token_decimals: number;
|
|
693
|
+
source_token_symbol: string;
|
|
694
|
+
destination_amount: string;
|
|
695
|
+
destination_amount_usd: string | null;
|
|
696
|
+
destination_token_decimals: number;
|
|
697
|
+
destination_token_symbol: string;
|
|
698
|
+
estimated_price_impact_percent: number | null;
|
|
699
|
+
estimated_fees_usd: string | null;
|
|
700
|
+
}
|
|
701
|
+
/**
|
|
702
|
+
* Get a deposit quote: how much source token is needed to receive a
|
|
703
|
+
* specific destination amount, accounting for bridge fees and slippage.
|
|
704
|
+
* Results are cached server-side for 1 minute.
|
|
705
|
+
*/
|
|
706
|
+
declare function getDepositQuote(request: DepositQuoteRequest, publishableKey?: string): Promise<DepositQuote>;
|
|
707
|
+
type HypercoreActionType = "spot_send" | "usd_send";
|
|
708
|
+
interface BuildHypercoreTransactionRequest {
|
|
709
|
+
action_type: HypercoreActionType;
|
|
710
|
+
signature_chain_type: string;
|
|
711
|
+
signature_chain_id: string;
|
|
712
|
+
recipient_address: string;
|
|
713
|
+
token_address: string;
|
|
714
|
+
token_symbol?: string;
|
|
715
|
+
amount: string;
|
|
716
|
+
}
|
|
717
|
+
interface BuildHypercoreTransactionResponse {
|
|
718
|
+
typed_data: Record<string, unknown>;
|
|
719
|
+
action_payload: Record<string, unknown>;
|
|
720
|
+
nonce: number;
|
|
721
|
+
}
|
|
722
|
+
interface SendHypercoreTransactionRequest {
|
|
723
|
+
action_payload: Record<string, unknown>;
|
|
724
|
+
signature: string;
|
|
725
|
+
nonce: number;
|
|
726
|
+
}
|
|
727
|
+
interface SendHypercoreTransactionResponse {
|
|
728
|
+
status: string;
|
|
729
|
+
response?: unknown;
|
|
730
|
+
}
|
|
731
|
+
/**
|
|
732
|
+
* Build EIP-712 typed data + action for a HyperCore transaction.
|
|
733
|
+
* Returns everything the frontend needs to sign and then submit.
|
|
734
|
+
*/
|
|
735
|
+
declare function buildHypercoreTransaction(request: BuildHypercoreTransactionRequest, publishableKey?: string): Promise<BuildHypercoreTransactionResponse>;
|
|
736
|
+
/**
|
|
737
|
+
* Send a signed HyperCore transaction via the backend proxy.
|
|
738
|
+
* Pass the action + nonce from buildHypercoreTransaction and
|
|
739
|
+
* the signature from eth_signTypedData_v4.
|
|
740
|
+
*/
|
|
741
|
+
declare function sendHypercoreTransaction(request: SendHypercoreTransactionRequest, publishableKey?: string): Promise<SendHypercoreTransactionResponse>;
|
|
603
742
|
|
|
604
743
|
/**
|
|
605
744
|
* User IP information interface
|
|
@@ -692,7 +831,33 @@ declare const i18n: {
|
|
|
692
831
|
intentAddressNote: string;
|
|
693
832
|
};
|
|
694
833
|
};
|
|
834
|
+
withdrawModal: {
|
|
835
|
+
title: string;
|
|
836
|
+
withdrawCrypto: {
|
|
837
|
+
title: string;
|
|
838
|
+
subtitle: string;
|
|
839
|
+
};
|
|
840
|
+
selectToken: string;
|
|
841
|
+
receiveToken: string;
|
|
842
|
+
receiveChain: string;
|
|
843
|
+
recipientAddress: string;
|
|
844
|
+
recipientAddressPlaceholder: string;
|
|
845
|
+
amount: string;
|
|
846
|
+
amountPlaceholder: string;
|
|
847
|
+
balance: string;
|
|
848
|
+
minimum: string;
|
|
849
|
+
withdraw: string;
|
|
850
|
+
invalidAddress: string;
|
|
851
|
+
invalidAmount: string;
|
|
852
|
+
verifyingAddress: string;
|
|
853
|
+
loading: string;
|
|
854
|
+
noTokensAvailable: string;
|
|
855
|
+
sourceToken: string;
|
|
856
|
+
review: string;
|
|
857
|
+
confirm: string;
|
|
858
|
+
back: string;
|
|
859
|
+
};
|
|
695
860
|
};
|
|
696
861
|
type I18nStrings = typeof i18n;
|
|
697
862
|
|
|
698
|
-
export { type AddressBalanceResponse, type AddressBalancesResponse, type AddressValidationFailureCode, type AddressValidationMetadata, type AutoSwapRequest, type AutoSwapResponse, type BuildSolanaTransactionRequest, type BuildSolanaTransactionResponse, type ChainType, type CreateDepositAddressRequest, type CreateExchangeSessionRequest, type CreateExchangeSessionResponse, type DefaultTokenChain, type DefaultTokenMetadata, type DefaultTokenResponse, type DepositAddressResponse, type ExchangeProviderInfo, type ExchangeProvidersResponse, type ExchangeSessionStartParams, type ExchangeWalletAddress, ExecutionStatus, type FeaturedToken, type FiatCurrenciesResponse, type FiatCurrency, type GetExchangesQuery, type I18nStrings, type IconUrl, IneligibilityReason, type IpAddressResponse, type OnrampQuote, type OnrampQuotesRequest, type OnrampQuotesResponse, type OnrampSessionRequest, type OnrampSessionResponse, type PaymentNetwork, type PollExecutionsRequest, type PollExecutionsResponse, type ProjectConfigResponse, type QueryExecutionsRequest, type QueryExecutionsResponse, SOLANA_USDC_ADDRESS, type SendSolanaTransactionRequest, type SendSolanaTransactionResponse, type SupportedChain, type SupportedDepositTokensResponse, type SupportedToken, type TokenBalance, type TokenChain, type TokenChainIconUrl, type TokenChainsResponse, type TokenIconUrl, type TokenInfo, type TokenMetadata, type UserIpInfo, type VerifyAddressRequest, type VerifyAddressResponse, type Wallet, buildSolanaTransaction, createDepositAddress, createExchangeSession, createOnrampSession, getAddressBalance, getAddressBalances, getApiBaseUrl, getChainName, getDefaultOnrampToken, getExchangeSessionStartUrl, getExchanges, getFiatCurrencies, getIconUrl, getIconUrlWithCdn, getIpAddress, getOnrampQuotes, getOnrampSessionStartUrl, getPreferredIconUrl, getProjectConfig, getSupportedDepositTokens, getTokenChains, getTokenMetadata, getWalletByChainType, i18n, pollDirectExecutions, queryExecutions, sendSolanaTransaction, setApiConfig, useUserIp, verifyRecipientAddress };
|
|
863
|
+
export { ActionType, type AddressBalanceResponse, type AddressBalancesResponse, type AddressValidationFailureCode, type AddressValidationMetadata, type AutoSwapRequest, type AutoSwapResponse, 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 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 I18nStrings, type IconUrl, IneligibilityReason, type IpAddressResponse, type OnrampQuote, type OnrampQuotesRequest, type OnrampQuotesResponse, type OnrampSessionRequest, type OnrampSessionResponse, type PaymentIntent, type PaymentIntentDepositAddress, type PaymentIntentExecutionsResponse, type PaymentNetwork, type PollExecutionsRequest, type PollExecutionsResponse, type ProjectConfigResponse, type QueryExecutionsRequest, type QueryExecutionsResponse, SOLANA_USDC_ADDRESS, type SendHypercoreTransactionRequest, type SendHypercoreTransactionResponse, type SendSolanaTransactionRequest, type SendSolanaTransactionResponse, type SupportedChain, type SupportedDepositTokensResponse, type SupportedDestinationTokensResponse, 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, createDepositAddress, createExchangeSession, createOnrampSession, 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 };
|
package/dist/index.d.ts
CHANGED
|
@@ -36,12 +36,18 @@ interface Wallet {
|
|
|
36
36
|
interface DepositAddressResponse {
|
|
37
37
|
data: Wallet[];
|
|
38
38
|
}
|
|
39
|
+
declare enum ActionType {
|
|
40
|
+
Deposit = "deposit",
|
|
41
|
+
Withdraw = "withdraw"
|
|
42
|
+
}
|
|
39
43
|
interface CreateDepositAddressRequest {
|
|
40
44
|
external_user_id: string;
|
|
41
45
|
destination_chain_type: string;
|
|
42
46
|
destination_chain_id: string;
|
|
43
47
|
destination_token_address: string;
|
|
44
48
|
recipient_address: string;
|
|
49
|
+
/** @default ActionType.Deposit */
|
|
50
|
+
action_type?: ActionType;
|
|
45
51
|
client_metadata?: Record<string, unknown>;
|
|
46
52
|
}
|
|
47
53
|
/**
|
|
@@ -116,6 +122,7 @@ interface AutoSwapResponse {
|
|
|
116
122
|
declare const SOLANA_USDC_ADDRESS = "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v";
|
|
117
123
|
interface QueryExecutionsRequest {
|
|
118
124
|
external_user_id: string;
|
|
125
|
+
action_type?: ActionType;
|
|
119
126
|
}
|
|
120
127
|
interface QueryExecutionsResponse {
|
|
121
128
|
data: AutoSwapResponse[];
|
|
@@ -123,12 +130,12 @@ interface QueryExecutionsResponse {
|
|
|
123
130
|
has_more: boolean;
|
|
124
131
|
}
|
|
125
132
|
/**
|
|
126
|
-
* Query
|
|
127
|
-
* Returns ALL executions - filter client-side for new ones
|
|
133
|
+
* Query direct executions for a user, optionally filtered by action type.
|
|
128
134
|
* @param externalUserId - External user ID
|
|
129
135
|
* @param publishableKey - Optional publishable key, defaults to configured key
|
|
136
|
+
* @param actionType - Optional filter: ActionType.Deposit or ActionType.Withdraw
|
|
130
137
|
*/
|
|
131
|
-
declare function queryExecutions(externalUserId: string, publishableKey?: string): Promise<QueryExecutionsResponse>;
|
|
138
|
+
declare function queryExecutions(externalUserId: string, publishableKey?: string, actionType?: ActionType): Promise<QueryExecutionsResponse>;
|
|
132
139
|
interface PollExecutionsRequest {
|
|
133
140
|
deposit_wallet_id: string;
|
|
134
141
|
}
|
|
@@ -155,6 +162,30 @@ interface SupportedChain {
|
|
|
155
162
|
estimated_processing_time: number | null;
|
|
156
163
|
minimum_deposit_amount_usd: number;
|
|
157
164
|
}
|
|
165
|
+
interface DestinationTokenChain {
|
|
166
|
+
chain_id: string;
|
|
167
|
+
chain_name: string;
|
|
168
|
+
chain_type: string;
|
|
169
|
+
token_address: string;
|
|
170
|
+
decimals: number;
|
|
171
|
+
icon_url: string;
|
|
172
|
+
icon_urls?: IconUrl[];
|
|
173
|
+
}
|
|
174
|
+
interface DestinationToken {
|
|
175
|
+
symbol: string;
|
|
176
|
+
name: string;
|
|
177
|
+
icon_url: string;
|
|
178
|
+
icon_urls?: IconUrl[];
|
|
179
|
+
chains: DestinationTokenChain[];
|
|
180
|
+
}
|
|
181
|
+
interface SupportedDestinationTokensResponse {
|
|
182
|
+
data: DestinationToken[];
|
|
183
|
+
}
|
|
184
|
+
/**
|
|
185
|
+
* Get supported destination tokens (used for withdraw flow)
|
|
186
|
+
* @param publishableKey - Optional publishable key, defaults to configured key
|
|
187
|
+
*/
|
|
188
|
+
declare function getSupportedDestinationTokens(publishableKey?: string): Promise<SupportedDestinationTokensResponse>;
|
|
158
189
|
interface SupportedToken {
|
|
159
190
|
symbol: string;
|
|
160
191
|
name: string;
|
|
@@ -600,6 +631,114 @@ interface SendSolanaTransactionResponse {
|
|
|
600
631
|
* @returns Transaction signature (hash) that can be used to track the transaction
|
|
601
632
|
*/
|
|
602
633
|
declare function sendSolanaTransaction(request: SendSolanaTransactionRequest, publishableKey?: string): Promise<SendSolanaTransactionResponse>;
|
|
634
|
+
interface PaymentIntentDepositAddress {
|
|
635
|
+
id: string;
|
|
636
|
+
chain_type: ChainType;
|
|
637
|
+
address_type: string | null;
|
|
638
|
+
address: string;
|
|
639
|
+
}
|
|
640
|
+
interface PaymentIntent {
|
|
641
|
+
id: string;
|
|
642
|
+
user_id: string | null;
|
|
643
|
+
amount: string;
|
|
644
|
+
amount_usd: string;
|
|
645
|
+
amount_received: string;
|
|
646
|
+
amount_received_usd: string;
|
|
647
|
+
currency: string;
|
|
648
|
+
status: string;
|
|
649
|
+
client_secret: string;
|
|
650
|
+
destination_network: string | null;
|
|
651
|
+
destination_chain_type: ChainType;
|
|
652
|
+
destination_chain_id: string;
|
|
653
|
+
destination_token_address: string;
|
|
654
|
+
recipient_address: string;
|
|
655
|
+
destination_token_decimals: number;
|
|
656
|
+
deposit_addresses: PaymentIntentDepositAddress[];
|
|
657
|
+
metadata: Record<string, string> | null;
|
|
658
|
+
description: string | null;
|
|
659
|
+
livemode: boolean;
|
|
660
|
+
settlement_tolerance_percent: number;
|
|
661
|
+
canceled_at: string | null;
|
|
662
|
+
cancellation_reason: string | null;
|
|
663
|
+
expires_at: string | null;
|
|
664
|
+
created_at: string;
|
|
665
|
+
updated_at: string;
|
|
666
|
+
}
|
|
667
|
+
/**
|
|
668
|
+
* Retrieve a payment intent by its client secret.
|
|
669
|
+
* Uses the public endpoint that requires a publishable key header.
|
|
670
|
+
*/
|
|
671
|
+
declare function retrievePaymentIntent(clientSecret: string, publishableKey?: string): Promise<PaymentIntent>;
|
|
672
|
+
interface PaymentIntentExecutionsResponse {
|
|
673
|
+
data: AutoSwapResponse[];
|
|
674
|
+
}
|
|
675
|
+
/**
|
|
676
|
+
* List all executions (deposits/swaps) for a payment intent.
|
|
677
|
+
* Authenticates via client_secret and publishable key.
|
|
678
|
+
*/
|
|
679
|
+
declare function listPaymentIntentExecutions(clientSecret: string, publishableKey?: string): Promise<PaymentIntentExecutionsResponse>;
|
|
680
|
+
interface DepositQuoteRequest {
|
|
681
|
+
source_chain_type: string;
|
|
682
|
+
source_chain_id: string;
|
|
683
|
+
source_token_address: string;
|
|
684
|
+
destination_amount: string;
|
|
685
|
+
destination_chain_type: string;
|
|
686
|
+
destination_chain_id: string;
|
|
687
|
+
destination_token_address: string;
|
|
688
|
+
}
|
|
689
|
+
interface DepositQuote {
|
|
690
|
+
source_amount: string;
|
|
691
|
+
source_amount_usd: string | null;
|
|
692
|
+
source_token_decimals: number;
|
|
693
|
+
source_token_symbol: string;
|
|
694
|
+
destination_amount: string;
|
|
695
|
+
destination_amount_usd: string | null;
|
|
696
|
+
destination_token_decimals: number;
|
|
697
|
+
destination_token_symbol: string;
|
|
698
|
+
estimated_price_impact_percent: number | null;
|
|
699
|
+
estimated_fees_usd: string | null;
|
|
700
|
+
}
|
|
701
|
+
/**
|
|
702
|
+
* Get a deposit quote: how much source token is needed to receive a
|
|
703
|
+
* specific destination amount, accounting for bridge fees and slippage.
|
|
704
|
+
* Results are cached server-side for 1 minute.
|
|
705
|
+
*/
|
|
706
|
+
declare function getDepositQuote(request: DepositQuoteRequest, publishableKey?: string): Promise<DepositQuote>;
|
|
707
|
+
type HypercoreActionType = "spot_send" | "usd_send";
|
|
708
|
+
interface BuildHypercoreTransactionRequest {
|
|
709
|
+
action_type: HypercoreActionType;
|
|
710
|
+
signature_chain_type: string;
|
|
711
|
+
signature_chain_id: string;
|
|
712
|
+
recipient_address: string;
|
|
713
|
+
token_address: string;
|
|
714
|
+
token_symbol?: string;
|
|
715
|
+
amount: string;
|
|
716
|
+
}
|
|
717
|
+
interface BuildHypercoreTransactionResponse {
|
|
718
|
+
typed_data: Record<string, unknown>;
|
|
719
|
+
action_payload: Record<string, unknown>;
|
|
720
|
+
nonce: number;
|
|
721
|
+
}
|
|
722
|
+
interface SendHypercoreTransactionRequest {
|
|
723
|
+
action_payload: Record<string, unknown>;
|
|
724
|
+
signature: string;
|
|
725
|
+
nonce: number;
|
|
726
|
+
}
|
|
727
|
+
interface SendHypercoreTransactionResponse {
|
|
728
|
+
status: string;
|
|
729
|
+
response?: unknown;
|
|
730
|
+
}
|
|
731
|
+
/**
|
|
732
|
+
* Build EIP-712 typed data + action for a HyperCore transaction.
|
|
733
|
+
* Returns everything the frontend needs to sign and then submit.
|
|
734
|
+
*/
|
|
735
|
+
declare function buildHypercoreTransaction(request: BuildHypercoreTransactionRequest, publishableKey?: string): Promise<BuildHypercoreTransactionResponse>;
|
|
736
|
+
/**
|
|
737
|
+
* Send a signed HyperCore transaction via the backend proxy.
|
|
738
|
+
* Pass the action + nonce from buildHypercoreTransaction and
|
|
739
|
+
* the signature from eth_signTypedData_v4.
|
|
740
|
+
*/
|
|
741
|
+
declare function sendHypercoreTransaction(request: SendHypercoreTransactionRequest, publishableKey?: string): Promise<SendHypercoreTransactionResponse>;
|
|
603
742
|
|
|
604
743
|
/**
|
|
605
744
|
* User IP information interface
|
|
@@ -692,7 +831,33 @@ declare const i18n: {
|
|
|
692
831
|
intentAddressNote: string;
|
|
693
832
|
};
|
|
694
833
|
};
|
|
834
|
+
withdrawModal: {
|
|
835
|
+
title: string;
|
|
836
|
+
withdrawCrypto: {
|
|
837
|
+
title: string;
|
|
838
|
+
subtitle: string;
|
|
839
|
+
};
|
|
840
|
+
selectToken: string;
|
|
841
|
+
receiveToken: string;
|
|
842
|
+
receiveChain: string;
|
|
843
|
+
recipientAddress: string;
|
|
844
|
+
recipientAddressPlaceholder: string;
|
|
845
|
+
amount: string;
|
|
846
|
+
amountPlaceholder: string;
|
|
847
|
+
balance: string;
|
|
848
|
+
minimum: string;
|
|
849
|
+
withdraw: string;
|
|
850
|
+
invalidAddress: string;
|
|
851
|
+
invalidAmount: string;
|
|
852
|
+
verifyingAddress: string;
|
|
853
|
+
loading: string;
|
|
854
|
+
noTokensAvailable: string;
|
|
855
|
+
sourceToken: string;
|
|
856
|
+
review: string;
|
|
857
|
+
confirm: string;
|
|
858
|
+
back: string;
|
|
859
|
+
};
|
|
695
860
|
};
|
|
696
861
|
type I18nStrings = typeof i18n;
|
|
697
862
|
|
|
698
|
-
export { type AddressBalanceResponse, type AddressBalancesResponse, type AddressValidationFailureCode, type AddressValidationMetadata, type AutoSwapRequest, type AutoSwapResponse, type BuildSolanaTransactionRequest, type BuildSolanaTransactionResponse, type ChainType, type CreateDepositAddressRequest, type CreateExchangeSessionRequest, type CreateExchangeSessionResponse, type DefaultTokenChain, type DefaultTokenMetadata, type DefaultTokenResponse, type DepositAddressResponse, type ExchangeProviderInfo, type ExchangeProvidersResponse, type ExchangeSessionStartParams, type ExchangeWalletAddress, ExecutionStatus, type FeaturedToken, type FiatCurrenciesResponse, type FiatCurrency, type GetExchangesQuery, type I18nStrings, type IconUrl, IneligibilityReason, type IpAddressResponse, type OnrampQuote, type OnrampQuotesRequest, type OnrampQuotesResponse, type OnrampSessionRequest, type OnrampSessionResponse, type PaymentNetwork, type PollExecutionsRequest, type PollExecutionsResponse, type ProjectConfigResponse, type QueryExecutionsRequest, type QueryExecutionsResponse, SOLANA_USDC_ADDRESS, type SendSolanaTransactionRequest, type SendSolanaTransactionResponse, type SupportedChain, type SupportedDepositTokensResponse, type SupportedToken, type TokenBalance, type TokenChain, type TokenChainIconUrl, type TokenChainsResponse, type TokenIconUrl, type TokenInfo, type TokenMetadata, type UserIpInfo, type VerifyAddressRequest, type VerifyAddressResponse, type Wallet, buildSolanaTransaction, createDepositAddress, createExchangeSession, createOnrampSession, getAddressBalance, getAddressBalances, getApiBaseUrl, getChainName, getDefaultOnrampToken, getExchangeSessionStartUrl, getExchanges, getFiatCurrencies, getIconUrl, getIconUrlWithCdn, getIpAddress, getOnrampQuotes, getOnrampSessionStartUrl, getPreferredIconUrl, getProjectConfig, getSupportedDepositTokens, getTokenChains, getTokenMetadata, getWalletByChainType, i18n, pollDirectExecutions, queryExecutions, sendSolanaTransaction, setApiConfig, useUserIp, verifyRecipientAddress };
|
|
863
|
+
export { ActionType, type AddressBalanceResponse, type AddressBalancesResponse, type AddressValidationFailureCode, type AddressValidationMetadata, type AutoSwapRequest, type AutoSwapResponse, 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 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 I18nStrings, type IconUrl, IneligibilityReason, type IpAddressResponse, type OnrampQuote, type OnrampQuotesRequest, type OnrampQuotesResponse, type OnrampSessionRequest, type OnrampSessionResponse, type PaymentIntent, type PaymentIntentDepositAddress, type PaymentIntentExecutionsResponse, type PaymentNetwork, type PollExecutionsRequest, type PollExecutionsResponse, type ProjectConfigResponse, type QueryExecutionsRequest, type QueryExecutionsResponse, SOLANA_USDC_ADDRESS, type SendHypercoreTransactionRequest, type SendHypercoreTransactionResponse, type SendSolanaTransactionRequest, type SendSolanaTransactionResponse, type SupportedChain, type SupportedDepositTokensResponse, type SupportedDestinationTokensResponse, 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, createDepositAddress, createExchangeSession, createOnrampSession, 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 };
|
package/dist/index.js
CHANGED
|
@@ -20,9 +20,11 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
20
20
|
// src/index.ts
|
|
21
21
|
var index_exports = {};
|
|
22
22
|
__export(index_exports, {
|
|
23
|
+
ActionType: () => ActionType,
|
|
23
24
|
ExecutionStatus: () => ExecutionStatus,
|
|
24
25
|
IneligibilityReason: () => IneligibilityReason,
|
|
25
26
|
SOLANA_USDC_ADDRESS: () => SOLANA_USDC_ADDRESS,
|
|
27
|
+
buildHypercoreTransaction: () => buildHypercoreTransaction,
|
|
26
28
|
buildSolanaTransaction: () => buildSolanaTransaction,
|
|
27
29
|
createDepositAddress: () => createDepositAddress,
|
|
28
30
|
createExchangeSession: () => createExchangeSession,
|
|
@@ -32,6 +34,7 @@ __export(index_exports, {
|
|
|
32
34
|
getApiBaseUrl: () => getApiBaseUrl,
|
|
33
35
|
getChainName: () => getChainName,
|
|
34
36
|
getDefaultOnrampToken: () => getDefaultOnrampToken,
|
|
37
|
+
getDepositQuote: () => getDepositQuote,
|
|
35
38
|
getExchangeSessionStartUrl: () => getExchangeSessionStartUrl,
|
|
36
39
|
getExchanges: () => getExchanges,
|
|
37
40
|
getFiatCurrencies: () => getFiatCurrencies,
|
|
@@ -43,12 +46,16 @@ __export(index_exports, {
|
|
|
43
46
|
getPreferredIconUrl: () => getPreferredIconUrl,
|
|
44
47
|
getProjectConfig: () => getProjectConfig,
|
|
45
48
|
getSupportedDepositTokens: () => getSupportedDepositTokens,
|
|
49
|
+
getSupportedDestinationTokens: () => getSupportedDestinationTokens,
|
|
46
50
|
getTokenChains: () => getTokenChains,
|
|
47
51
|
getTokenMetadata: () => getTokenMetadata,
|
|
48
52
|
getWalletByChainType: () => getWalletByChainType,
|
|
49
53
|
i18n: () => i18n,
|
|
54
|
+
listPaymentIntentExecutions: () => listPaymentIntentExecutions,
|
|
50
55
|
pollDirectExecutions: () => pollDirectExecutions,
|
|
51
56
|
queryExecutions: () => queryExecutions,
|
|
57
|
+
retrievePaymentIntent: () => retrievePaymentIntent,
|
|
58
|
+
sendHypercoreTransaction: () => sendHypercoreTransaction,
|
|
52
59
|
sendSolanaTransaction: () => sendSolanaTransaction,
|
|
53
60
|
setApiConfig: () => setApiConfig,
|
|
54
61
|
useUserIp: () => useUserIp,
|
|
@@ -109,6 +116,11 @@ function getIconUrlWithCdn(iconPath, assetCdnUrl) {
|
|
|
109
116
|
const baseUrl = assetCdnUrl.endsWith("/") ? assetCdnUrl.slice(0, -1) : assetCdnUrl;
|
|
110
117
|
return `${baseUrl}/api/public${normalizedPath}`;
|
|
111
118
|
}
|
|
119
|
+
var ActionType = /* @__PURE__ */ ((ActionType2) => {
|
|
120
|
+
ActionType2["Deposit"] = "deposit";
|
|
121
|
+
ActionType2["Withdraw"] = "withdraw";
|
|
122
|
+
return ActionType2;
|
|
123
|
+
})(ActionType || {});
|
|
112
124
|
async function createDepositAddress(overrides, publishableKey) {
|
|
113
125
|
if (!overrides?.external_user_id) {
|
|
114
126
|
throw new Error("external_user_id is required");
|
|
@@ -119,6 +131,7 @@ async function createDepositAddress(overrides, publishableKey) {
|
|
|
119
131
|
destination_chain_id: overrides?.destination_chain_id || DEFAULT_CONFIG.destinationChainId || "8453",
|
|
120
132
|
destination_token_address: overrides?.destination_token_address || DEFAULT_CONFIG.destinationTokenAddress || "0x833589fcd6edb6e08f4c7c32d4f71b54bda02913",
|
|
121
133
|
recipient_address: overrides?.recipient_address || DEFAULT_CONFIG.recipientAddress || "0x309a4154a2CD4153Da886E780890C9cb5161553C",
|
|
134
|
+
...overrides?.action_type ? { action_type: overrides.action_type } : {},
|
|
122
135
|
client_metadata: overrides?.client_metadata || {}
|
|
123
136
|
};
|
|
124
137
|
const pk = publishableKey || DEFAULT_PUBLISHABLE_KEY;
|
|
@@ -150,9 +163,13 @@ var ExecutionStatus = /* @__PURE__ */ ((ExecutionStatus2) => {
|
|
|
150
163
|
return ExecutionStatus2;
|
|
151
164
|
})(ExecutionStatus || {});
|
|
152
165
|
var SOLANA_USDC_ADDRESS = "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v";
|
|
153
|
-
async function queryExecutions(externalUserId, publishableKey) {
|
|
166
|
+
async function queryExecutions(externalUserId, publishableKey, actionType) {
|
|
154
167
|
const pk = publishableKey || DEFAULT_PUBLISHABLE_KEY;
|
|
155
168
|
validatePublishableKey(pk);
|
|
169
|
+
const body = {
|
|
170
|
+
external_user_id: externalUserId,
|
|
171
|
+
...actionType ? { action_type: actionType } : {}
|
|
172
|
+
};
|
|
156
173
|
const response = await fetch(
|
|
157
174
|
`${API_BASE_URL}/v1/public/direct_executions/query`,
|
|
158
175
|
{
|
|
@@ -162,9 +179,7 @@ async function queryExecutions(externalUserId, publishableKey) {
|
|
|
162
179
|
"x-publishable-key": pk,
|
|
163
180
|
"Content-Type": "application/json"
|
|
164
181
|
},
|
|
165
|
-
body: JSON.stringify(
|
|
166
|
-
external_user_id: externalUserId
|
|
167
|
-
})
|
|
182
|
+
body: JSON.stringify(body)
|
|
168
183
|
}
|
|
169
184
|
);
|
|
170
185
|
if (!response.ok) {
|
|
@@ -192,6 +207,26 @@ async function pollDirectExecutions(request, publishableKey) {
|
|
|
192
207
|
}
|
|
193
208
|
return response.json();
|
|
194
209
|
}
|
|
210
|
+
async function getSupportedDestinationTokens(publishableKey) {
|
|
211
|
+
const pk = publishableKey || DEFAULT_PUBLISHABLE_KEY;
|
|
212
|
+
validatePublishableKey(pk);
|
|
213
|
+
const response = await fetch(
|
|
214
|
+
`${API_BASE_URL}/v1/public/tokens/supported_destination_tokens`,
|
|
215
|
+
{
|
|
216
|
+
method: "GET",
|
|
217
|
+
headers: {
|
|
218
|
+
accept: "application/json",
|
|
219
|
+
"x-publishable-key": pk
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
);
|
|
223
|
+
if (!response.ok) {
|
|
224
|
+
throw new Error(
|
|
225
|
+
`Failed to fetch supported destination tokens: ${response.statusText}`
|
|
226
|
+
);
|
|
227
|
+
}
|
|
228
|
+
return response.json();
|
|
229
|
+
}
|
|
195
230
|
async function getSupportedDepositTokens(publishableKey, options) {
|
|
196
231
|
const pk = publishableKey || DEFAULT_PUBLISHABLE_KEY;
|
|
197
232
|
validatePublishableKey(pk);
|
|
@@ -576,6 +611,119 @@ async function sendSolanaTransaction(request, publishableKey) {
|
|
|
576
611
|
}
|
|
577
612
|
return response.json();
|
|
578
613
|
}
|
|
614
|
+
async function retrievePaymentIntent(clientSecret, publishableKey) {
|
|
615
|
+
const pk = publishableKey || DEFAULT_PUBLISHABLE_KEY;
|
|
616
|
+
validatePublishableKey(pk);
|
|
617
|
+
const response = await fetch(
|
|
618
|
+
`${API_BASE_URL}/v1/public/payment_intents/retrieve`,
|
|
619
|
+
{
|
|
620
|
+
method: "POST",
|
|
621
|
+
headers: {
|
|
622
|
+
accept: "application/json",
|
|
623
|
+
"x-publishable-key": pk,
|
|
624
|
+
"Content-Type": "application/json"
|
|
625
|
+
},
|
|
626
|
+
body: JSON.stringify({ client_secret: clientSecret })
|
|
627
|
+
}
|
|
628
|
+
);
|
|
629
|
+
if (!response.ok) {
|
|
630
|
+
const error = await response.json().catch(() => ({ message: response.statusText }));
|
|
631
|
+
throw new Error(
|
|
632
|
+
`Failed to retrieve payment intent: ${error.message || response.statusText}`
|
|
633
|
+
);
|
|
634
|
+
}
|
|
635
|
+
return response.json();
|
|
636
|
+
}
|
|
637
|
+
async function listPaymentIntentExecutions(clientSecret, publishableKey) {
|
|
638
|
+
const pk = publishableKey || DEFAULT_PUBLISHABLE_KEY;
|
|
639
|
+
validatePublishableKey(pk);
|
|
640
|
+
const response = await fetch(
|
|
641
|
+
`${API_BASE_URL}/v1/public/payment_intents/executions`,
|
|
642
|
+
{
|
|
643
|
+
method: "POST",
|
|
644
|
+
headers: {
|
|
645
|
+
accept: "application/json",
|
|
646
|
+
"x-publishable-key": pk,
|
|
647
|
+
"Content-Type": "application/json"
|
|
648
|
+
},
|
|
649
|
+
body: JSON.stringify({ client_secret: clientSecret })
|
|
650
|
+
}
|
|
651
|
+
);
|
|
652
|
+
if (!response.ok) {
|
|
653
|
+
const error = await response.json().catch(() => ({ message: response.statusText }));
|
|
654
|
+
throw new Error(
|
|
655
|
+
`Failed to list payment intent executions: ${error.message || response.statusText}`
|
|
656
|
+
);
|
|
657
|
+
}
|
|
658
|
+
return response.json();
|
|
659
|
+
}
|
|
660
|
+
async function getDepositQuote(request, publishableKey) {
|
|
661
|
+
const pk = publishableKey || DEFAULT_PUBLISHABLE_KEY;
|
|
662
|
+
validatePublishableKey(pk);
|
|
663
|
+
const response = await fetch(`${API_BASE_URL}/v1/public/quotes`, {
|
|
664
|
+
method: "POST",
|
|
665
|
+
headers: {
|
|
666
|
+
accept: "application/json",
|
|
667
|
+
"x-publishable-key": pk,
|
|
668
|
+
"Content-Type": "application/json"
|
|
669
|
+
},
|
|
670
|
+
body: JSON.stringify(request)
|
|
671
|
+
});
|
|
672
|
+
if (!response.ok) {
|
|
673
|
+
const error = await response.json().catch(() => ({ message: response.statusText }));
|
|
674
|
+
throw new Error(
|
|
675
|
+
`Failed to get deposit quote: ${error.message || response.statusText}`
|
|
676
|
+
);
|
|
677
|
+
}
|
|
678
|
+
const json = await response.json();
|
|
679
|
+
return json.data;
|
|
680
|
+
}
|
|
681
|
+
async function buildHypercoreTransaction(request, publishableKey) {
|
|
682
|
+
const pk = publishableKey || DEFAULT_PUBLISHABLE_KEY;
|
|
683
|
+
validatePublishableKey(pk);
|
|
684
|
+
const response = await fetch(
|
|
685
|
+
`${API_BASE_URL}/v1/public/transactions/hypercore/build`,
|
|
686
|
+
{
|
|
687
|
+
method: "POST",
|
|
688
|
+
headers: {
|
|
689
|
+
accept: "application/json",
|
|
690
|
+
"x-publishable-key": pk,
|
|
691
|
+
"Content-Type": "application/json"
|
|
692
|
+
},
|
|
693
|
+
body: JSON.stringify(request)
|
|
694
|
+
}
|
|
695
|
+
);
|
|
696
|
+
if (!response.ok) {
|
|
697
|
+
const error = await response.json().catch(() => ({ message: response.statusText }));
|
|
698
|
+
throw new Error(
|
|
699
|
+
`Failed to build HyperCore transaction: ${error.message || response.statusText}`
|
|
700
|
+
);
|
|
701
|
+
}
|
|
702
|
+
return response.json();
|
|
703
|
+
}
|
|
704
|
+
async function sendHypercoreTransaction(request, publishableKey) {
|
|
705
|
+
const pk = publishableKey || DEFAULT_PUBLISHABLE_KEY;
|
|
706
|
+
validatePublishableKey(pk);
|
|
707
|
+
const response = await fetch(
|
|
708
|
+
`${API_BASE_URL}/v1/public/transactions/hypercore/send`,
|
|
709
|
+
{
|
|
710
|
+
method: "POST",
|
|
711
|
+
headers: {
|
|
712
|
+
accept: "application/json",
|
|
713
|
+
"x-publishable-key": pk,
|
|
714
|
+
"Content-Type": "application/json"
|
|
715
|
+
},
|
|
716
|
+
body: JSON.stringify(request)
|
|
717
|
+
}
|
|
718
|
+
);
|
|
719
|
+
if (!response.ok) {
|
|
720
|
+
const error = await response.json().catch(() => ({ message: response.statusText }));
|
|
721
|
+
throw new Error(
|
|
722
|
+
`Failed to send HyperCore transaction: ${error.message || response.statusText}`
|
|
723
|
+
);
|
|
724
|
+
}
|
|
725
|
+
return response.json();
|
|
726
|
+
}
|
|
579
727
|
|
|
580
728
|
// src/hooks/use-user-ip.ts
|
|
581
729
|
var import_react_query = require("@tanstack/react-query");
|
|
@@ -675,6 +823,32 @@ var en_default = {
|
|
|
675
823
|
youReceive: "You receive",
|
|
676
824
|
intentAddressNote: "The wallet address displayed in the payment provider is a temporary deposit address. Your funds will be automatically converted and deposited into your account."
|
|
677
825
|
}
|
|
826
|
+
},
|
|
827
|
+
withdrawModal: {
|
|
828
|
+
title: "Withdraw",
|
|
829
|
+
withdrawCrypto: {
|
|
830
|
+
title: "Withdraw with Crypto",
|
|
831
|
+
subtitle: "Send to any wallet address"
|
|
832
|
+
},
|
|
833
|
+
selectToken: "Select withdrawal token",
|
|
834
|
+
receiveToken: "Receive token",
|
|
835
|
+
receiveChain: "Receive chain",
|
|
836
|
+
recipientAddress: "Recipient address",
|
|
837
|
+
recipientAddressPlaceholder: "Enter wallet address",
|
|
838
|
+
amount: "Amount",
|
|
839
|
+
amountPlaceholder: "0.00",
|
|
840
|
+
balance: "Balance",
|
|
841
|
+
minimum: "min",
|
|
842
|
+
withdraw: "Withdraw",
|
|
843
|
+
invalidAddress: "Please enter a valid address",
|
|
844
|
+
invalidAmount: "Please enter a valid amount",
|
|
845
|
+
verifyingAddress: "Verifying address...",
|
|
846
|
+
loading: "Loading...",
|
|
847
|
+
noTokensAvailable: "No tokens available",
|
|
848
|
+
sourceToken: "Source token",
|
|
849
|
+
review: "Review",
|
|
850
|
+
confirm: "Confirm Withdrawal",
|
|
851
|
+
back: "Back"
|
|
678
852
|
}
|
|
679
853
|
};
|
|
680
854
|
|
|
@@ -682,9 +856,11 @@ var en_default = {
|
|
|
682
856
|
var i18n = en_default;
|
|
683
857
|
// Annotate the CommonJS export names for ESM import in node:
|
|
684
858
|
0 && (module.exports = {
|
|
859
|
+
ActionType,
|
|
685
860
|
ExecutionStatus,
|
|
686
861
|
IneligibilityReason,
|
|
687
862
|
SOLANA_USDC_ADDRESS,
|
|
863
|
+
buildHypercoreTransaction,
|
|
688
864
|
buildSolanaTransaction,
|
|
689
865
|
createDepositAddress,
|
|
690
866
|
createExchangeSession,
|
|
@@ -694,6 +870,7 @@ var i18n = en_default;
|
|
|
694
870
|
getApiBaseUrl,
|
|
695
871
|
getChainName,
|
|
696
872
|
getDefaultOnrampToken,
|
|
873
|
+
getDepositQuote,
|
|
697
874
|
getExchangeSessionStartUrl,
|
|
698
875
|
getExchanges,
|
|
699
876
|
getFiatCurrencies,
|
|
@@ -705,12 +882,16 @@ var i18n = en_default;
|
|
|
705
882
|
getPreferredIconUrl,
|
|
706
883
|
getProjectConfig,
|
|
707
884
|
getSupportedDepositTokens,
|
|
885
|
+
getSupportedDestinationTokens,
|
|
708
886
|
getTokenChains,
|
|
709
887
|
getTokenMetadata,
|
|
710
888
|
getWalletByChainType,
|
|
711
889
|
i18n,
|
|
890
|
+
listPaymentIntentExecutions,
|
|
712
891
|
pollDirectExecutions,
|
|
713
892
|
queryExecutions,
|
|
893
|
+
retrievePaymentIntent,
|
|
894
|
+
sendHypercoreTransaction,
|
|
714
895
|
sendSolanaTransaction,
|
|
715
896
|
setApiConfig,
|
|
716
897
|
useUserIp,
|
package/dist/index.mjs
CHANGED
|
@@ -51,6 +51,11 @@ function getIconUrlWithCdn(iconPath, assetCdnUrl) {
|
|
|
51
51
|
const baseUrl = assetCdnUrl.endsWith("/") ? assetCdnUrl.slice(0, -1) : assetCdnUrl;
|
|
52
52
|
return `${baseUrl}/api/public${normalizedPath}`;
|
|
53
53
|
}
|
|
54
|
+
var ActionType = /* @__PURE__ */ ((ActionType2) => {
|
|
55
|
+
ActionType2["Deposit"] = "deposit";
|
|
56
|
+
ActionType2["Withdraw"] = "withdraw";
|
|
57
|
+
return ActionType2;
|
|
58
|
+
})(ActionType || {});
|
|
54
59
|
async function createDepositAddress(overrides, publishableKey) {
|
|
55
60
|
if (!overrides?.external_user_id) {
|
|
56
61
|
throw new Error("external_user_id is required");
|
|
@@ -61,6 +66,7 @@ async function createDepositAddress(overrides, publishableKey) {
|
|
|
61
66
|
destination_chain_id: overrides?.destination_chain_id || DEFAULT_CONFIG.destinationChainId || "8453",
|
|
62
67
|
destination_token_address: overrides?.destination_token_address || DEFAULT_CONFIG.destinationTokenAddress || "0x833589fcd6edb6e08f4c7c32d4f71b54bda02913",
|
|
63
68
|
recipient_address: overrides?.recipient_address || DEFAULT_CONFIG.recipientAddress || "0x309a4154a2CD4153Da886E780890C9cb5161553C",
|
|
69
|
+
...overrides?.action_type ? { action_type: overrides.action_type } : {},
|
|
64
70
|
client_metadata: overrides?.client_metadata || {}
|
|
65
71
|
};
|
|
66
72
|
const pk = publishableKey || DEFAULT_PUBLISHABLE_KEY;
|
|
@@ -92,9 +98,13 @@ var ExecutionStatus = /* @__PURE__ */ ((ExecutionStatus2) => {
|
|
|
92
98
|
return ExecutionStatus2;
|
|
93
99
|
})(ExecutionStatus || {});
|
|
94
100
|
var SOLANA_USDC_ADDRESS = "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v";
|
|
95
|
-
async function queryExecutions(externalUserId, publishableKey) {
|
|
101
|
+
async function queryExecutions(externalUserId, publishableKey, actionType) {
|
|
96
102
|
const pk = publishableKey || DEFAULT_PUBLISHABLE_KEY;
|
|
97
103
|
validatePublishableKey(pk);
|
|
104
|
+
const body = {
|
|
105
|
+
external_user_id: externalUserId,
|
|
106
|
+
...actionType ? { action_type: actionType } : {}
|
|
107
|
+
};
|
|
98
108
|
const response = await fetch(
|
|
99
109
|
`${API_BASE_URL}/v1/public/direct_executions/query`,
|
|
100
110
|
{
|
|
@@ -104,9 +114,7 @@ async function queryExecutions(externalUserId, publishableKey) {
|
|
|
104
114
|
"x-publishable-key": pk,
|
|
105
115
|
"Content-Type": "application/json"
|
|
106
116
|
},
|
|
107
|
-
body: JSON.stringify(
|
|
108
|
-
external_user_id: externalUserId
|
|
109
|
-
})
|
|
117
|
+
body: JSON.stringify(body)
|
|
110
118
|
}
|
|
111
119
|
);
|
|
112
120
|
if (!response.ok) {
|
|
@@ -134,6 +142,26 @@ async function pollDirectExecutions(request, publishableKey) {
|
|
|
134
142
|
}
|
|
135
143
|
return response.json();
|
|
136
144
|
}
|
|
145
|
+
async function getSupportedDestinationTokens(publishableKey) {
|
|
146
|
+
const pk = publishableKey || DEFAULT_PUBLISHABLE_KEY;
|
|
147
|
+
validatePublishableKey(pk);
|
|
148
|
+
const response = await fetch(
|
|
149
|
+
`${API_BASE_URL}/v1/public/tokens/supported_destination_tokens`,
|
|
150
|
+
{
|
|
151
|
+
method: "GET",
|
|
152
|
+
headers: {
|
|
153
|
+
accept: "application/json",
|
|
154
|
+
"x-publishable-key": pk
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
);
|
|
158
|
+
if (!response.ok) {
|
|
159
|
+
throw new Error(
|
|
160
|
+
`Failed to fetch supported destination tokens: ${response.statusText}`
|
|
161
|
+
);
|
|
162
|
+
}
|
|
163
|
+
return response.json();
|
|
164
|
+
}
|
|
137
165
|
async function getSupportedDepositTokens(publishableKey, options) {
|
|
138
166
|
const pk = publishableKey || DEFAULT_PUBLISHABLE_KEY;
|
|
139
167
|
validatePublishableKey(pk);
|
|
@@ -518,6 +546,119 @@ async function sendSolanaTransaction(request, publishableKey) {
|
|
|
518
546
|
}
|
|
519
547
|
return response.json();
|
|
520
548
|
}
|
|
549
|
+
async function retrievePaymentIntent(clientSecret, publishableKey) {
|
|
550
|
+
const pk = publishableKey || DEFAULT_PUBLISHABLE_KEY;
|
|
551
|
+
validatePublishableKey(pk);
|
|
552
|
+
const response = await fetch(
|
|
553
|
+
`${API_BASE_URL}/v1/public/payment_intents/retrieve`,
|
|
554
|
+
{
|
|
555
|
+
method: "POST",
|
|
556
|
+
headers: {
|
|
557
|
+
accept: "application/json",
|
|
558
|
+
"x-publishable-key": pk,
|
|
559
|
+
"Content-Type": "application/json"
|
|
560
|
+
},
|
|
561
|
+
body: JSON.stringify({ client_secret: clientSecret })
|
|
562
|
+
}
|
|
563
|
+
);
|
|
564
|
+
if (!response.ok) {
|
|
565
|
+
const error = await response.json().catch(() => ({ message: response.statusText }));
|
|
566
|
+
throw new Error(
|
|
567
|
+
`Failed to retrieve payment intent: ${error.message || response.statusText}`
|
|
568
|
+
);
|
|
569
|
+
}
|
|
570
|
+
return response.json();
|
|
571
|
+
}
|
|
572
|
+
async function listPaymentIntentExecutions(clientSecret, publishableKey) {
|
|
573
|
+
const pk = publishableKey || DEFAULT_PUBLISHABLE_KEY;
|
|
574
|
+
validatePublishableKey(pk);
|
|
575
|
+
const response = await fetch(
|
|
576
|
+
`${API_BASE_URL}/v1/public/payment_intents/executions`,
|
|
577
|
+
{
|
|
578
|
+
method: "POST",
|
|
579
|
+
headers: {
|
|
580
|
+
accept: "application/json",
|
|
581
|
+
"x-publishable-key": pk,
|
|
582
|
+
"Content-Type": "application/json"
|
|
583
|
+
},
|
|
584
|
+
body: JSON.stringify({ client_secret: clientSecret })
|
|
585
|
+
}
|
|
586
|
+
);
|
|
587
|
+
if (!response.ok) {
|
|
588
|
+
const error = await response.json().catch(() => ({ message: response.statusText }));
|
|
589
|
+
throw new Error(
|
|
590
|
+
`Failed to list payment intent executions: ${error.message || response.statusText}`
|
|
591
|
+
);
|
|
592
|
+
}
|
|
593
|
+
return response.json();
|
|
594
|
+
}
|
|
595
|
+
async function getDepositQuote(request, publishableKey) {
|
|
596
|
+
const pk = publishableKey || DEFAULT_PUBLISHABLE_KEY;
|
|
597
|
+
validatePublishableKey(pk);
|
|
598
|
+
const response = await fetch(`${API_BASE_URL}/v1/public/quotes`, {
|
|
599
|
+
method: "POST",
|
|
600
|
+
headers: {
|
|
601
|
+
accept: "application/json",
|
|
602
|
+
"x-publishable-key": pk,
|
|
603
|
+
"Content-Type": "application/json"
|
|
604
|
+
},
|
|
605
|
+
body: JSON.stringify(request)
|
|
606
|
+
});
|
|
607
|
+
if (!response.ok) {
|
|
608
|
+
const error = await response.json().catch(() => ({ message: response.statusText }));
|
|
609
|
+
throw new Error(
|
|
610
|
+
`Failed to get deposit quote: ${error.message || response.statusText}`
|
|
611
|
+
);
|
|
612
|
+
}
|
|
613
|
+
const json = await response.json();
|
|
614
|
+
return json.data;
|
|
615
|
+
}
|
|
616
|
+
async function buildHypercoreTransaction(request, publishableKey) {
|
|
617
|
+
const pk = publishableKey || DEFAULT_PUBLISHABLE_KEY;
|
|
618
|
+
validatePublishableKey(pk);
|
|
619
|
+
const response = await fetch(
|
|
620
|
+
`${API_BASE_URL}/v1/public/transactions/hypercore/build`,
|
|
621
|
+
{
|
|
622
|
+
method: "POST",
|
|
623
|
+
headers: {
|
|
624
|
+
accept: "application/json",
|
|
625
|
+
"x-publishable-key": pk,
|
|
626
|
+
"Content-Type": "application/json"
|
|
627
|
+
},
|
|
628
|
+
body: JSON.stringify(request)
|
|
629
|
+
}
|
|
630
|
+
);
|
|
631
|
+
if (!response.ok) {
|
|
632
|
+
const error = await response.json().catch(() => ({ message: response.statusText }));
|
|
633
|
+
throw new Error(
|
|
634
|
+
`Failed to build HyperCore transaction: ${error.message || response.statusText}`
|
|
635
|
+
);
|
|
636
|
+
}
|
|
637
|
+
return response.json();
|
|
638
|
+
}
|
|
639
|
+
async function sendHypercoreTransaction(request, publishableKey) {
|
|
640
|
+
const pk = publishableKey || DEFAULT_PUBLISHABLE_KEY;
|
|
641
|
+
validatePublishableKey(pk);
|
|
642
|
+
const response = await fetch(
|
|
643
|
+
`${API_BASE_URL}/v1/public/transactions/hypercore/send`,
|
|
644
|
+
{
|
|
645
|
+
method: "POST",
|
|
646
|
+
headers: {
|
|
647
|
+
accept: "application/json",
|
|
648
|
+
"x-publishable-key": pk,
|
|
649
|
+
"Content-Type": "application/json"
|
|
650
|
+
},
|
|
651
|
+
body: JSON.stringify(request)
|
|
652
|
+
}
|
|
653
|
+
);
|
|
654
|
+
if (!response.ok) {
|
|
655
|
+
const error = await response.json().catch(() => ({ message: response.statusText }));
|
|
656
|
+
throw new Error(
|
|
657
|
+
`Failed to send HyperCore transaction: ${error.message || response.statusText}`
|
|
658
|
+
);
|
|
659
|
+
}
|
|
660
|
+
return response.json();
|
|
661
|
+
}
|
|
521
662
|
|
|
522
663
|
// src/hooks/use-user-ip.ts
|
|
523
664
|
import { useQuery } from "@tanstack/react-query";
|
|
@@ -617,15 +758,43 @@ var en_default = {
|
|
|
617
758
|
youReceive: "You receive",
|
|
618
759
|
intentAddressNote: "The wallet address displayed in the payment provider is a temporary deposit address. Your funds will be automatically converted and deposited into your account."
|
|
619
760
|
}
|
|
761
|
+
},
|
|
762
|
+
withdrawModal: {
|
|
763
|
+
title: "Withdraw",
|
|
764
|
+
withdrawCrypto: {
|
|
765
|
+
title: "Withdraw with Crypto",
|
|
766
|
+
subtitle: "Send to any wallet address"
|
|
767
|
+
},
|
|
768
|
+
selectToken: "Select withdrawal token",
|
|
769
|
+
receiveToken: "Receive token",
|
|
770
|
+
receiveChain: "Receive chain",
|
|
771
|
+
recipientAddress: "Recipient address",
|
|
772
|
+
recipientAddressPlaceholder: "Enter wallet address",
|
|
773
|
+
amount: "Amount",
|
|
774
|
+
amountPlaceholder: "0.00",
|
|
775
|
+
balance: "Balance",
|
|
776
|
+
minimum: "min",
|
|
777
|
+
withdraw: "Withdraw",
|
|
778
|
+
invalidAddress: "Please enter a valid address",
|
|
779
|
+
invalidAmount: "Please enter a valid amount",
|
|
780
|
+
verifyingAddress: "Verifying address...",
|
|
781
|
+
loading: "Loading...",
|
|
782
|
+
noTokensAvailable: "No tokens available",
|
|
783
|
+
sourceToken: "Source token",
|
|
784
|
+
review: "Review",
|
|
785
|
+
confirm: "Confirm Withdrawal",
|
|
786
|
+
back: "Back"
|
|
620
787
|
}
|
|
621
788
|
};
|
|
622
789
|
|
|
623
790
|
// src/lib/i18n.ts
|
|
624
791
|
var i18n = en_default;
|
|
625
792
|
export {
|
|
793
|
+
ActionType,
|
|
626
794
|
ExecutionStatus,
|
|
627
795
|
IneligibilityReason,
|
|
628
796
|
SOLANA_USDC_ADDRESS,
|
|
797
|
+
buildHypercoreTransaction,
|
|
629
798
|
buildSolanaTransaction,
|
|
630
799
|
createDepositAddress,
|
|
631
800
|
createExchangeSession,
|
|
@@ -635,6 +804,7 @@ export {
|
|
|
635
804
|
getApiBaseUrl,
|
|
636
805
|
getChainName,
|
|
637
806
|
getDefaultOnrampToken,
|
|
807
|
+
getDepositQuote,
|
|
638
808
|
getExchangeSessionStartUrl,
|
|
639
809
|
getExchanges,
|
|
640
810
|
getFiatCurrencies,
|
|
@@ -646,12 +816,16 @@ export {
|
|
|
646
816
|
getPreferredIconUrl,
|
|
647
817
|
getProjectConfig,
|
|
648
818
|
getSupportedDepositTokens,
|
|
819
|
+
getSupportedDestinationTokens,
|
|
649
820
|
getTokenChains,
|
|
650
821
|
getTokenMetadata,
|
|
651
822
|
getWalletByChainType,
|
|
652
823
|
i18n,
|
|
824
|
+
listPaymentIntentExecutions,
|
|
653
825
|
pollDirectExecutions,
|
|
654
826
|
queryExecutions,
|
|
827
|
+
retrievePaymentIntent,
|
|
828
|
+
sendHypercoreTransaction,
|
|
655
829
|
sendSolanaTransaction,
|
|
656
830
|
setApiConfig,
|
|
657
831
|
useUserIp,
|