@volr/react 0.1.92 → 0.1.93
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.cjs +82 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +151 -1
- package/dist/index.d.ts +151 -1
- package/dist/index.js +82 -1
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.d.cts
CHANGED
|
@@ -730,6 +730,156 @@ declare function uploadBlobViaPresign(params: {
|
|
|
730
730
|
*/
|
|
731
731
|
declare function useInternalAuth(): InternalAuthContextType;
|
|
732
732
|
|
|
733
|
+
/**
|
|
734
|
+
* Payment types for SDK
|
|
735
|
+
*/
|
|
736
|
+
type PaymentStatus = 'PENDING' | 'PROCESSING' | 'CONFIRMED' | 'FAILED' | 'CANCELLED' | 'EXPIRED';
|
|
737
|
+
interface PaymentItem {
|
|
738
|
+
/** Item name displayed in payment modal */
|
|
739
|
+
name: string;
|
|
740
|
+
/** Item description (optional) */
|
|
741
|
+
description?: string;
|
|
742
|
+
/** Item image URL (optional) */
|
|
743
|
+
image?: string;
|
|
744
|
+
}
|
|
745
|
+
interface PayOptions {
|
|
746
|
+
/** Amount in token units (before decimals applied) */
|
|
747
|
+
amount: number;
|
|
748
|
+
/** Item information to display in payment modal */
|
|
749
|
+
item?: PaymentItem;
|
|
750
|
+
/** Client-side order/reference ID */
|
|
751
|
+
referenceId?: string;
|
|
752
|
+
/** Custom metadata (max 50 keys) */
|
|
753
|
+
metadata?: Record<string, string>;
|
|
754
|
+
/** Idempotency key to prevent duplicate payments */
|
|
755
|
+
idempotencyKey?: string;
|
|
756
|
+
/** Payment expiration time in seconds (default: 900 = 15 minutes) */
|
|
757
|
+
expiresInSec?: number;
|
|
758
|
+
/** Callback handlers */
|
|
759
|
+
handlers?: PaymentHandlers;
|
|
760
|
+
}
|
|
761
|
+
interface PaymentHandlers {
|
|
762
|
+
/** Called when payment is created with ID */
|
|
763
|
+
onCreated?: (payment: {
|
|
764
|
+
id: string;
|
|
765
|
+
}) => void;
|
|
766
|
+
/** Called when transaction is broadcasted with txHash */
|
|
767
|
+
onProcessing?: (payment: {
|
|
768
|
+
id: string;
|
|
769
|
+
txHash: string;
|
|
770
|
+
}) => void;
|
|
771
|
+
/** Called when payment is confirmed on-chain */
|
|
772
|
+
onSuccess?: (result: PaymentResult) => void;
|
|
773
|
+
/** Called when payment fails */
|
|
774
|
+
onError?: (error: PaymentError) => void;
|
|
775
|
+
/** Called when user cancels the payment */
|
|
776
|
+
onCancel?: () => void;
|
|
777
|
+
}
|
|
778
|
+
interface PaymentToken {
|
|
779
|
+
id: string;
|
|
780
|
+
symbol: string;
|
|
781
|
+
chainId: number;
|
|
782
|
+
decimals: number;
|
|
783
|
+
}
|
|
784
|
+
interface PaymentResult {
|
|
785
|
+
id: string;
|
|
786
|
+
status: PaymentStatus;
|
|
787
|
+
txHash: string | null;
|
|
788
|
+
amount: string;
|
|
789
|
+
totalUsd: string | null;
|
|
790
|
+
tokenPriceUsd: string | null;
|
|
791
|
+
token: PaymentToken;
|
|
792
|
+
itemName: string | null;
|
|
793
|
+
itemDescription: string | null;
|
|
794
|
+
itemImage: string | null;
|
|
795
|
+
referenceId: string | null;
|
|
796
|
+
metadata: Record<string, string> | null;
|
|
797
|
+
createdAt: string;
|
|
798
|
+
confirmedAt: string | null;
|
|
799
|
+
}
|
|
800
|
+
interface PaymentError {
|
|
801
|
+
code: string;
|
|
802
|
+
message: string;
|
|
803
|
+
}
|
|
804
|
+
interface PaymentHistoryResult {
|
|
805
|
+
payments: PaymentResult[];
|
|
806
|
+
total: number;
|
|
807
|
+
}
|
|
808
|
+
interface PaymentHistoryOptions {
|
|
809
|
+
take?: number;
|
|
810
|
+
skip?: number;
|
|
811
|
+
status?: PaymentStatus;
|
|
812
|
+
}
|
|
813
|
+
/**
|
|
814
|
+
* Payment handle returned from pay() function
|
|
815
|
+
*/
|
|
816
|
+
interface PaymentHandle {
|
|
817
|
+
/** Payment ID */
|
|
818
|
+
id: string;
|
|
819
|
+
/** Current payment status */
|
|
820
|
+
status: PaymentStatus;
|
|
821
|
+
/** Wait for payment to complete (CONFIRMED/FAILED/CANCELLED) */
|
|
822
|
+
wait: () => Promise<PaymentResult>;
|
|
823
|
+
/** Cancel the payment (only works for PENDING status) */
|
|
824
|
+
cancel: () => Promise<void>;
|
|
825
|
+
}
|
|
826
|
+
/**
|
|
827
|
+
* Internal payment context for PaymentModal
|
|
828
|
+
*/
|
|
829
|
+
interface PaymentContext {
|
|
830
|
+
payment: PaymentResult | null;
|
|
831
|
+
options: PayOptions;
|
|
832
|
+
isOpen: boolean;
|
|
833
|
+
close: () => void;
|
|
834
|
+
onPaymentCreated: (payment: PaymentResult) => void;
|
|
835
|
+
onPaymentProcessing: (payment: PaymentResult & {
|
|
836
|
+
txHash: string;
|
|
837
|
+
}) => void;
|
|
838
|
+
onPaymentComplete: (result: PaymentResult) => void;
|
|
839
|
+
onPaymentError: (error: PaymentError) => void;
|
|
840
|
+
onPaymentCancel: () => void;
|
|
841
|
+
}
|
|
842
|
+
|
|
843
|
+
/**
|
|
844
|
+
* useVolrPay hook - Payment functionality for Volr SDK
|
|
845
|
+
*
|
|
846
|
+
* This hook provides the core payment API methods.
|
|
847
|
+
* For UI integration (PaymentModal), use useVolrPayUI from @volr/react-ui
|
|
848
|
+
*/
|
|
849
|
+
|
|
850
|
+
interface UseVolrPayReturn {
|
|
851
|
+
/**
|
|
852
|
+
* Create a payment (without UI)
|
|
853
|
+
* For UI integration, use useVolrPayUI from @volr/react-ui
|
|
854
|
+
*/
|
|
855
|
+
createPayment: (options: PayOptions) => Promise<PaymentResult>;
|
|
856
|
+
/**
|
|
857
|
+
* Check payment status by ID
|
|
858
|
+
*/
|
|
859
|
+
checkPayment: (paymentId: string) => Promise<PaymentResult>;
|
|
860
|
+
/**
|
|
861
|
+
* Get payment history for current user
|
|
862
|
+
*/
|
|
863
|
+
getPaymentHistory: (options?: PaymentHistoryOptions) => Promise<PaymentHistoryResult>;
|
|
864
|
+
/**
|
|
865
|
+
* Update payment to PROCESSING status (link transaction)
|
|
866
|
+
*/
|
|
867
|
+
updatePaymentToProcessing: (paymentId: string, transactionId: string) => Promise<PaymentResult>;
|
|
868
|
+
/**
|
|
869
|
+
* Cancel a pending payment
|
|
870
|
+
*/
|
|
871
|
+
cancelPayment: (paymentId: string) => Promise<PaymentResult>;
|
|
872
|
+
/**
|
|
873
|
+
* Poll payment status until completion
|
|
874
|
+
*/
|
|
875
|
+
pollPaymentStatus: (paymentId: string) => Promise<PaymentResult>;
|
|
876
|
+
/**
|
|
877
|
+
* Whether a payment operation is loading
|
|
878
|
+
*/
|
|
879
|
+
isLoading: boolean;
|
|
880
|
+
}
|
|
881
|
+
declare function useVolrPay(): UseVolrPayReturn;
|
|
882
|
+
|
|
733
883
|
/**
|
|
734
884
|
* Passkey adapter for WebAuthn
|
|
735
885
|
* Implements PasskeyProviderPort interface
|
|
@@ -1141,4 +1291,4 @@ declare function getUserCredentials(client: APIClient): Promise<Array<{
|
|
|
1141
1291
|
createdAt: string;
|
|
1142
1292
|
}>>;
|
|
1143
1293
|
|
|
1144
|
-
export { type ApiResponse, type AuthRefreshResponseDto, type AuthResult, type BuildCallOptions, type ContractAnalysisResult, DEFAULT_EXPIRES_IN_SEC, DEFAULT_MODE, type DepositAsset$1 as DepositAsset, type DepositConfig, type ERC20BalanceComparison, type Erc20Token$1 as Erc20Token, type EvmClient, type KeyStorageType, type MigrationCompleteParams, type MigrationCompleteResult, type MigrationError, type MigrationMessage, type MigrationRequestParams, type MigrationRequestResult, type MigrationSeedRequest, type MigrationSeedResponse, type MpcConnectionStep, type NetworkDto, type NetworkInfo, type PasskeyAdapterOptions, type PasskeyEnrollmentStep, PasskeyNotFoundError, type PlatformCheckResult, type PrfInputDto, PrfNotSupportedError, type SendBatchOverloads, type SendTxOptions, type SignerType, type SiweSession, type SiweSessionStatus, type SocialProvider, type TransactionDto, type TransactionStatus, type UseMpcConnectionReturn, type UsePasskeyEnrollmentReturn, type UseVolrAuthCallbackOptions, type UseVolrAuthCallbackReturn, type UseVolrLoginReturn, UserCancelledError, type UserDto, type VolrClient, type VolrConfig, type VolrContextValue, VolrProvider, type VolrUser, type WalletStateComparison, analyzeContractForEIP7702, buildCall, buildCalls, checkPrfExtensionAvailable, checkPrfSupport, compareERC20Balances, compareWalletStates, completeMigration, createGetNetworkInfo, createPasskeyAdapter, debugTransactionFailure, defaultIdempotencyKey, diagnoseTransactionFailure, getERC20Balance, getPasskeyAuthGuidance, getUserCredentials, getWalletState, isEIP7702Delegated, isUserCancelledError, listenForSeedRequests, normalizeHex, normalizeHexArray, openMigrationPopup, requestMigration, requestSeedFromOpener, sendSeedToPopup, uploadBlobViaPresign, useDepositListener, useInternalAuth, useMpcConnection, usePasskeyEnrollment, useVolr, useVolrAuthCallback, useVolrContext, useVolrLogin };
|
|
1294
|
+
export { type ApiResponse, type AuthRefreshResponseDto, type AuthResult, type BuildCallOptions, type ContractAnalysisResult, DEFAULT_EXPIRES_IN_SEC, DEFAULT_MODE, type DepositAsset$1 as DepositAsset, type DepositConfig, type ERC20BalanceComparison, type Erc20Token$1 as Erc20Token, type EvmClient, type KeyStorageType, type MigrationCompleteParams, type MigrationCompleteResult, type MigrationError, type MigrationMessage, type MigrationRequestParams, type MigrationRequestResult, type MigrationSeedRequest, type MigrationSeedResponse, type MpcConnectionStep, type NetworkDto, type NetworkInfo, type PasskeyAdapterOptions, type PasskeyEnrollmentStep, PasskeyNotFoundError, type PayOptions, type PaymentContext, type PaymentError, type PaymentHandle, type PaymentHandlers, type PaymentHistoryOptions, type PaymentHistoryResult, type PaymentItem, type PaymentResult, type PaymentStatus, type PaymentToken, type PlatformCheckResult, type PrfInputDto, PrfNotSupportedError, type SendBatchOverloads, type SendTxOptions, type SignerType, type SiweSession, type SiweSessionStatus, type SocialProvider, type TransactionDto, type TransactionStatus, type UseMpcConnectionReturn, type UsePasskeyEnrollmentReturn, type UseVolrAuthCallbackOptions, type UseVolrAuthCallbackReturn, type UseVolrLoginReturn, type UseVolrPayReturn, UserCancelledError, type UserDto, type VolrClient, type VolrConfig, type VolrContextValue, VolrProvider, type VolrUser, type WalletStateComparison, analyzeContractForEIP7702, buildCall, buildCalls, checkPrfExtensionAvailable, checkPrfSupport, compareERC20Balances, compareWalletStates, completeMigration, createGetNetworkInfo, createPasskeyAdapter, debugTransactionFailure, defaultIdempotencyKey, diagnoseTransactionFailure, getERC20Balance, getPasskeyAuthGuidance, getUserCredentials, getWalletState, isEIP7702Delegated, isUserCancelledError, listenForSeedRequests, normalizeHex, normalizeHexArray, openMigrationPopup, requestMigration, requestSeedFromOpener, sendSeedToPopup, uploadBlobViaPresign, useDepositListener, useInternalAuth, useMpcConnection, usePasskeyEnrollment, useVolr, useVolrAuthCallback, useVolrContext, useVolrLogin, useVolrPay };
|
package/dist/index.d.ts
CHANGED
|
@@ -730,6 +730,156 @@ declare function uploadBlobViaPresign(params: {
|
|
|
730
730
|
*/
|
|
731
731
|
declare function useInternalAuth(): InternalAuthContextType;
|
|
732
732
|
|
|
733
|
+
/**
|
|
734
|
+
* Payment types for SDK
|
|
735
|
+
*/
|
|
736
|
+
type PaymentStatus = 'PENDING' | 'PROCESSING' | 'CONFIRMED' | 'FAILED' | 'CANCELLED' | 'EXPIRED';
|
|
737
|
+
interface PaymentItem {
|
|
738
|
+
/** Item name displayed in payment modal */
|
|
739
|
+
name: string;
|
|
740
|
+
/** Item description (optional) */
|
|
741
|
+
description?: string;
|
|
742
|
+
/** Item image URL (optional) */
|
|
743
|
+
image?: string;
|
|
744
|
+
}
|
|
745
|
+
interface PayOptions {
|
|
746
|
+
/** Amount in token units (before decimals applied) */
|
|
747
|
+
amount: number;
|
|
748
|
+
/** Item information to display in payment modal */
|
|
749
|
+
item?: PaymentItem;
|
|
750
|
+
/** Client-side order/reference ID */
|
|
751
|
+
referenceId?: string;
|
|
752
|
+
/** Custom metadata (max 50 keys) */
|
|
753
|
+
metadata?: Record<string, string>;
|
|
754
|
+
/** Idempotency key to prevent duplicate payments */
|
|
755
|
+
idempotencyKey?: string;
|
|
756
|
+
/** Payment expiration time in seconds (default: 900 = 15 minutes) */
|
|
757
|
+
expiresInSec?: number;
|
|
758
|
+
/** Callback handlers */
|
|
759
|
+
handlers?: PaymentHandlers;
|
|
760
|
+
}
|
|
761
|
+
interface PaymentHandlers {
|
|
762
|
+
/** Called when payment is created with ID */
|
|
763
|
+
onCreated?: (payment: {
|
|
764
|
+
id: string;
|
|
765
|
+
}) => void;
|
|
766
|
+
/** Called when transaction is broadcasted with txHash */
|
|
767
|
+
onProcessing?: (payment: {
|
|
768
|
+
id: string;
|
|
769
|
+
txHash: string;
|
|
770
|
+
}) => void;
|
|
771
|
+
/** Called when payment is confirmed on-chain */
|
|
772
|
+
onSuccess?: (result: PaymentResult) => void;
|
|
773
|
+
/** Called when payment fails */
|
|
774
|
+
onError?: (error: PaymentError) => void;
|
|
775
|
+
/** Called when user cancels the payment */
|
|
776
|
+
onCancel?: () => void;
|
|
777
|
+
}
|
|
778
|
+
interface PaymentToken {
|
|
779
|
+
id: string;
|
|
780
|
+
symbol: string;
|
|
781
|
+
chainId: number;
|
|
782
|
+
decimals: number;
|
|
783
|
+
}
|
|
784
|
+
interface PaymentResult {
|
|
785
|
+
id: string;
|
|
786
|
+
status: PaymentStatus;
|
|
787
|
+
txHash: string | null;
|
|
788
|
+
amount: string;
|
|
789
|
+
totalUsd: string | null;
|
|
790
|
+
tokenPriceUsd: string | null;
|
|
791
|
+
token: PaymentToken;
|
|
792
|
+
itemName: string | null;
|
|
793
|
+
itemDescription: string | null;
|
|
794
|
+
itemImage: string | null;
|
|
795
|
+
referenceId: string | null;
|
|
796
|
+
metadata: Record<string, string> | null;
|
|
797
|
+
createdAt: string;
|
|
798
|
+
confirmedAt: string | null;
|
|
799
|
+
}
|
|
800
|
+
interface PaymentError {
|
|
801
|
+
code: string;
|
|
802
|
+
message: string;
|
|
803
|
+
}
|
|
804
|
+
interface PaymentHistoryResult {
|
|
805
|
+
payments: PaymentResult[];
|
|
806
|
+
total: number;
|
|
807
|
+
}
|
|
808
|
+
interface PaymentHistoryOptions {
|
|
809
|
+
take?: number;
|
|
810
|
+
skip?: number;
|
|
811
|
+
status?: PaymentStatus;
|
|
812
|
+
}
|
|
813
|
+
/**
|
|
814
|
+
* Payment handle returned from pay() function
|
|
815
|
+
*/
|
|
816
|
+
interface PaymentHandle {
|
|
817
|
+
/** Payment ID */
|
|
818
|
+
id: string;
|
|
819
|
+
/** Current payment status */
|
|
820
|
+
status: PaymentStatus;
|
|
821
|
+
/** Wait for payment to complete (CONFIRMED/FAILED/CANCELLED) */
|
|
822
|
+
wait: () => Promise<PaymentResult>;
|
|
823
|
+
/** Cancel the payment (only works for PENDING status) */
|
|
824
|
+
cancel: () => Promise<void>;
|
|
825
|
+
}
|
|
826
|
+
/**
|
|
827
|
+
* Internal payment context for PaymentModal
|
|
828
|
+
*/
|
|
829
|
+
interface PaymentContext {
|
|
830
|
+
payment: PaymentResult | null;
|
|
831
|
+
options: PayOptions;
|
|
832
|
+
isOpen: boolean;
|
|
833
|
+
close: () => void;
|
|
834
|
+
onPaymentCreated: (payment: PaymentResult) => void;
|
|
835
|
+
onPaymentProcessing: (payment: PaymentResult & {
|
|
836
|
+
txHash: string;
|
|
837
|
+
}) => void;
|
|
838
|
+
onPaymentComplete: (result: PaymentResult) => void;
|
|
839
|
+
onPaymentError: (error: PaymentError) => void;
|
|
840
|
+
onPaymentCancel: () => void;
|
|
841
|
+
}
|
|
842
|
+
|
|
843
|
+
/**
|
|
844
|
+
* useVolrPay hook - Payment functionality for Volr SDK
|
|
845
|
+
*
|
|
846
|
+
* This hook provides the core payment API methods.
|
|
847
|
+
* For UI integration (PaymentModal), use useVolrPayUI from @volr/react-ui
|
|
848
|
+
*/
|
|
849
|
+
|
|
850
|
+
interface UseVolrPayReturn {
|
|
851
|
+
/**
|
|
852
|
+
* Create a payment (without UI)
|
|
853
|
+
* For UI integration, use useVolrPayUI from @volr/react-ui
|
|
854
|
+
*/
|
|
855
|
+
createPayment: (options: PayOptions) => Promise<PaymentResult>;
|
|
856
|
+
/**
|
|
857
|
+
* Check payment status by ID
|
|
858
|
+
*/
|
|
859
|
+
checkPayment: (paymentId: string) => Promise<PaymentResult>;
|
|
860
|
+
/**
|
|
861
|
+
* Get payment history for current user
|
|
862
|
+
*/
|
|
863
|
+
getPaymentHistory: (options?: PaymentHistoryOptions) => Promise<PaymentHistoryResult>;
|
|
864
|
+
/**
|
|
865
|
+
* Update payment to PROCESSING status (link transaction)
|
|
866
|
+
*/
|
|
867
|
+
updatePaymentToProcessing: (paymentId: string, transactionId: string) => Promise<PaymentResult>;
|
|
868
|
+
/**
|
|
869
|
+
* Cancel a pending payment
|
|
870
|
+
*/
|
|
871
|
+
cancelPayment: (paymentId: string) => Promise<PaymentResult>;
|
|
872
|
+
/**
|
|
873
|
+
* Poll payment status until completion
|
|
874
|
+
*/
|
|
875
|
+
pollPaymentStatus: (paymentId: string) => Promise<PaymentResult>;
|
|
876
|
+
/**
|
|
877
|
+
* Whether a payment operation is loading
|
|
878
|
+
*/
|
|
879
|
+
isLoading: boolean;
|
|
880
|
+
}
|
|
881
|
+
declare function useVolrPay(): UseVolrPayReturn;
|
|
882
|
+
|
|
733
883
|
/**
|
|
734
884
|
* Passkey adapter for WebAuthn
|
|
735
885
|
* Implements PasskeyProviderPort interface
|
|
@@ -1141,4 +1291,4 @@ declare function getUserCredentials(client: APIClient): Promise<Array<{
|
|
|
1141
1291
|
createdAt: string;
|
|
1142
1292
|
}>>;
|
|
1143
1293
|
|
|
1144
|
-
export { type ApiResponse, type AuthRefreshResponseDto, type AuthResult, type BuildCallOptions, type ContractAnalysisResult, DEFAULT_EXPIRES_IN_SEC, DEFAULT_MODE, type DepositAsset$1 as DepositAsset, type DepositConfig, type ERC20BalanceComparison, type Erc20Token$1 as Erc20Token, type EvmClient, type KeyStorageType, type MigrationCompleteParams, type MigrationCompleteResult, type MigrationError, type MigrationMessage, type MigrationRequestParams, type MigrationRequestResult, type MigrationSeedRequest, type MigrationSeedResponse, type MpcConnectionStep, type NetworkDto, type NetworkInfo, type PasskeyAdapterOptions, type PasskeyEnrollmentStep, PasskeyNotFoundError, type PlatformCheckResult, type PrfInputDto, PrfNotSupportedError, type SendBatchOverloads, type SendTxOptions, type SignerType, type SiweSession, type SiweSessionStatus, type SocialProvider, type TransactionDto, type TransactionStatus, type UseMpcConnectionReturn, type UsePasskeyEnrollmentReturn, type UseVolrAuthCallbackOptions, type UseVolrAuthCallbackReturn, type UseVolrLoginReturn, UserCancelledError, type UserDto, type VolrClient, type VolrConfig, type VolrContextValue, VolrProvider, type VolrUser, type WalletStateComparison, analyzeContractForEIP7702, buildCall, buildCalls, checkPrfExtensionAvailable, checkPrfSupport, compareERC20Balances, compareWalletStates, completeMigration, createGetNetworkInfo, createPasskeyAdapter, debugTransactionFailure, defaultIdempotencyKey, diagnoseTransactionFailure, getERC20Balance, getPasskeyAuthGuidance, getUserCredentials, getWalletState, isEIP7702Delegated, isUserCancelledError, listenForSeedRequests, normalizeHex, normalizeHexArray, openMigrationPopup, requestMigration, requestSeedFromOpener, sendSeedToPopup, uploadBlobViaPresign, useDepositListener, useInternalAuth, useMpcConnection, usePasskeyEnrollment, useVolr, useVolrAuthCallback, useVolrContext, useVolrLogin };
|
|
1294
|
+
export { type ApiResponse, type AuthRefreshResponseDto, type AuthResult, type BuildCallOptions, type ContractAnalysisResult, DEFAULT_EXPIRES_IN_SEC, DEFAULT_MODE, type DepositAsset$1 as DepositAsset, type DepositConfig, type ERC20BalanceComparison, type Erc20Token$1 as Erc20Token, type EvmClient, type KeyStorageType, type MigrationCompleteParams, type MigrationCompleteResult, type MigrationError, type MigrationMessage, type MigrationRequestParams, type MigrationRequestResult, type MigrationSeedRequest, type MigrationSeedResponse, type MpcConnectionStep, type NetworkDto, type NetworkInfo, type PasskeyAdapterOptions, type PasskeyEnrollmentStep, PasskeyNotFoundError, type PayOptions, type PaymentContext, type PaymentError, type PaymentHandle, type PaymentHandlers, type PaymentHistoryOptions, type PaymentHistoryResult, type PaymentItem, type PaymentResult, type PaymentStatus, type PaymentToken, type PlatformCheckResult, type PrfInputDto, PrfNotSupportedError, type SendBatchOverloads, type SendTxOptions, type SignerType, type SiweSession, type SiweSessionStatus, type SocialProvider, type TransactionDto, type TransactionStatus, type UseMpcConnectionReturn, type UsePasskeyEnrollmentReturn, type UseVolrAuthCallbackOptions, type UseVolrAuthCallbackReturn, type UseVolrLoginReturn, type UseVolrPayReturn, UserCancelledError, type UserDto, type VolrClient, type VolrConfig, type VolrContextValue, VolrProvider, type VolrUser, type WalletStateComparison, analyzeContractForEIP7702, buildCall, buildCalls, checkPrfExtensionAvailable, checkPrfSupport, compareERC20Balances, compareWalletStates, completeMigration, createGetNetworkInfo, createPasskeyAdapter, debugTransactionFailure, defaultIdempotencyKey, diagnoseTransactionFailure, getERC20Balance, getPasskeyAuthGuidance, getUserCredentials, getWalletState, isEIP7702Delegated, isUserCancelledError, listenForSeedRequests, normalizeHex, normalizeHexArray, openMigrationPopup, requestMigration, requestSeedFromOpener, sendSeedToPopup, uploadBlobViaPresign, useDepositListener, useInternalAuth, useMpcConnection, usePasskeyEnrollment, useVolr, useVolrAuthCallback, useVolrContext, useVolrLogin, useVolrPay };
|
package/dist/index.js
CHANGED
|
@@ -19596,6 +19596,87 @@ async function uploadBlobViaPresign(params) {
|
|
|
19596
19596
|
}
|
|
19597
19597
|
return { s3Key };
|
|
19598
19598
|
}
|
|
19599
|
+
var POLL_INTERVAL_MS = 2e3;
|
|
19600
|
+
var MAX_POLL_ATTEMPTS = 180;
|
|
19601
|
+
function useVolrPay() {
|
|
19602
|
+
const { client } = useInternalAuth();
|
|
19603
|
+
const [isLoading, setIsLoading] = useState(false);
|
|
19604
|
+
const createPayment = useCallback(
|
|
19605
|
+
async (options) => {
|
|
19606
|
+
setIsLoading(true);
|
|
19607
|
+
try {
|
|
19608
|
+
const response = await client.post("/payments", {
|
|
19609
|
+
amount: options.amount,
|
|
19610
|
+
item: options.item,
|
|
19611
|
+
referenceId: options.referenceId,
|
|
19612
|
+
metadata: options.metadata,
|
|
19613
|
+
idempotencyKey: options.idempotencyKey,
|
|
19614
|
+
expiresInSec: options.expiresInSec
|
|
19615
|
+
});
|
|
19616
|
+
return response;
|
|
19617
|
+
} finally {
|
|
19618
|
+
setIsLoading(false);
|
|
19619
|
+
}
|
|
19620
|
+
},
|
|
19621
|
+
[client]
|
|
19622
|
+
);
|
|
19623
|
+
const checkPayment = useCallback(
|
|
19624
|
+
async (paymentId) => {
|
|
19625
|
+
return client.get(`/payments/${paymentId}`);
|
|
19626
|
+
},
|
|
19627
|
+
[client]
|
|
19628
|
+
);
|
|
19629
|
+
const getPaymentHistory = useCallback(
|
|
19630
|
+
async (options = {}) => {
|
|
19631
|
+
const params = new URLSearchParams();
|
|
19632
|
+
if (options.take) params.append("take", String(options.take));
|
|
19633
|
+
if (options.skip) params.append("skip", String(options.skip));
|
|
19634
|
+
if (options.status) params.append("status", options.status);
|
|
19635
|
+
const queryString = params.toString();
|
|
19636
|
+
const url = queryString ? `/payments?${queryString}` : "/payments";
|
|
19637
|
+
return client.get(url);
|
|
19638
|
+
},
|
|
19639
|
+
[client]
|
|
19640
|
+
);
|
|
19641
|
+
const updatePaymentToProcessing = useCallback(
|
|
19642
|
+
async (paymentId, transactionId) => {
|
|
19643
|
+
return client.post(`/payments/${paymentId}/processing`, {
|
|
19644
|
+
transactionId
|
|
19645
|
+
});
|
|
19646
|
+
},
|
|
19647
|
+
[client]
|
|
19648
|
+
);
|
|
19649
|
+
const cancelPayment = useCallback(
|
|
19650
|
+
async (paymentId) => {
|
|
19651
|
+
return client.post(`/payments/${paymentId}/cancel`, {});
|
|
19652
|
+
},
|
|
19653
|
+
[client]
|
|
19654
|
+
);
|
|
19655
|
+
const pollPaymentStatus = useCallback(
|
|
19656
|
+
async (paymentId) => {
|
|
19657
|
+
let attempts = 0;
|
|
19658
|
+
while (attempts < MAX_POLL_ATTEMPTS) {
|
|
19659
|
+
const payment = await checkPayment(paymentId);
|
|
19660
|
+
if (payment.status === "CONFIRMED" || payment.status === "FAILED" || payment.status === "CANCELLED" || payment.status === "EXPIRED") {
|
|
19661
|
+
return payment;
|
|
19662
|
+
}
|
|
19663
|
+
await new Promise((resolve) => setTimeout(resolve, POLL_INTERVAL_MS));
|
|
19664
|
+
attempts++;
|
|
19665
|
+
}
|
|
19666
|
+
throw new Error("Payment polling timeout");
|
|
19667
|
+
},
|
|
19668
|
+
[checkPayment]
|
|
19669
|
+
);
|
|
19670
|
+
return {
|
|
19671
|
+
createPayment,
|
|
19672
|
+
checkPayment,
|
|
19673
|
+
getPaymentHistory,
|
|
19674
|
+
updatePaymentToProcessing,
|
|
19675
|
+
cancelPayment,
|
|
19676
|
+
pollPaymentStatus,
|
|
19677
|
+
isLoading
|
|
19678
|
+
};
|
|
19679
|
+
}
|
|
19599
19680
|
|
|
19600
19681
|
// src/utils/contract-analysis.ts
|
|
19601
19682
|
var EIP7702_PREFIX = "0xef0100";
|
|
@@ -20202,6 +20283,6 @@ async function getUserCredentials(client) {
|
|
|
20202
20283
|
(*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) *)
|
|
20203
20284
|
*/
|
|
20204
20285
|
|
|
20205
|
-
export { DEFAULT_EXPIRES_IN_SEC, DEFAULT_MODE, PasskeyNotFoundError, PrfNotSupportedError, UserCancelledError, VolrProvider, analyzeContractForEIP7702, buildCall, buildCalls, checkPrfExtensionAvailable, checkPrfSupport, compareERC20Balances, compareWalletStates, completeMigration, createGetNetworkInfo, createPasskeyAdapter, debugTransactionFailure, defaultIdempotencyKey, diagnoseTransactionFailure, getERC20Balance, getPasskeyAuthGuidance, getUserCredentials, getWalletState, isEIP7702Delegated, isUserCancelledError, listenForSeedRequests, normalizeHex, normalizeHexArray, openMigrationPopup, requestMigration, requestSeedFromOpener, sendSeedToPopup, uploadBlobViaPresign, useDepositListener, useInternalAuth, useMpcConnection, usePasskeyEnrollment, useVolr, useVolrAuthCallback, useVolrContext, useVolrLogin };
|
|
20286
|
+
export { DEFAULT_EXPIRES_IN_SEC, DEFAULT_MODE, PasskeyNotFoundError, PrfNotSupportedError, UserCancelledError, VolrProvider, analyzeContractForEIP7702, buildCall, buildCalls, checkPrfExtensionAvailable, checkPrfSupport, compareERC20Balances, compareWalletStates, completeMigration, createGetNetworkInfo, createPasskeyAdapter, debugTransactionFailure, defaultIdempotencyKey, diagnoseTransactionFailure, getERC20Balance, getPasskeyAuthGuidance, getUserCredentials, getWalletState, isEIP7702Delegated, isUserCancelledError, listenForSeedRequests, normalizeHex, normalizeHexArray, openMigrationPopup, requestMigration, requestSeedFromOpener, sendSeedToPopup, uploadBlobViaPresign, useDepositListener, useInternalAuth, useMpcConnection, usePasskeyEnrollment, useVolr, useVolrAuthCallback, useVolrContext, useVolrLogin, useVolrPay };
|
|
20206
20287
|
//# sourceMappingURL=index.js.map
|
|
20207
20288
|
//# sourceMappingURL=index.js.map
|