@volr/react 0.1.91 → 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 +104 -4
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +155 -1
- package/dist/index.d.ts +155 -1
- package/dist/index.js +104 -5
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.d.cts
CHANGED
|
@@ -111,6 +111,8 @@ interface PrfInputDto {
|
|
|
111
111
|
*/
|
|
112
112
|
interface UserDto {
|
|
113
113
|
id: string;
|
|
114
|
+
projectId: string;
|
|
115
|
+
projectName: string;
|
|
114
116
|
email: string;
|
|
115
117
|
accountId?: string;
|
|
116
118
|
evmAddress?: `0x${string}`;
|
|
@@ -200,6 +202,8 @@ interface DepositConfig {
|
|
|
200
202
|
*/
|
|
201
203
|
interface VolrUser {
|
|
202
204
|
id?: string;
|
|
205
|
+
projectId?: string;
|
|
206
|
+
projectName?: string;
|
|
203
207
|
email?: string;
|
|
204
208
|
accountId?: string;
|
|
205
209
|
evmAddress?: `0x${string}`;
|
|
@@ -726,6 +730,156 @@ declare function uploadBlobViaPresign(params: {
|
|
|
726
730
|
*/
|
|
727
731
|
declare function useInternalAuth(): InternalAuthContextType;
|
|
728
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
|
+
|
|
729
883
|
/**
|
|
730
884
|
* Passkey adapter for WebAuthn
|
|
731
885
|
* Implements PasskeyProviderPort interface
|
|
@@ -1137,4 +1291,4 @@ declare function getUserCredentials(client: APIClient): Promise<Array<{
|
|
|
1137
1291
|
createdAt: string;
|
|
1138
1292
|
}>>;
|
|
1139
1293
|
|
|
1140
|
-
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
|
@@ -111,6 +111,8 @@ interface PrfInputDto {
|
|
|
111
111
|
*/
|
|
112
112
|
interface UserDto {
|
|
113
113
|
id: string;
|
|
114
|
+
projectId: string;
|
|
115
|
+
projectName: string;
|
|
114
116
|
email: string;
|
|
115
117
|
accountId?: string;
|
|
116
118
|
evmAddress?: `0x${string}`;
|
|
@@ -200,6 +202,8 @@ interface DepositConfig {
|
|
|
200
202
|
*/
|
|
201
203
|
interface VolrUser {
|
|
202
204
|
id?: string;
|
|
205
|
+
projectId?: string;
|
|
206
|
+
projectName?: string;
|
|
203
207
|
email?: string;
|
|
204
208
|
accountId?: string;
|
|
205
209
|
evmAddress?: `0x${string}`;
|
|
@@ -726,6 +730,156 @@ declare function uploadBlobViaPresign(params: {
|
|
|
726
730
|
*/
|
|
727
731
|
declare function useInternalAuth(): InternalAuthContextType;
|
|
728
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
|
+
|
|
729
883
|
/**
|
|
730
884
|
* Passkey adapter for WebAuthn
|
|
731
885
|
* Implements PasskeyProviderPort interface
|
|
@@ -1137,4 +1291,4 @@ declare function getUserCredentials(client: APIClient): Promise<Array<{
|
|
|
1137
1291
|
createdAt: string;
|
|
1138
1292
|
}>>;
|
|
1139
1293
|
|
|
1140
|
-
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
|
@@ -18679,6 +18679,8 @@ function useVolrLogin() {
|
|
|
18679
18679
|
const toVolrUser = useCallback((u) => {
|
|
18680
18680
|
return {
|
|
18681
18681
|
id: u.id,
|
|
18682
|
+
projectId: u.projectId,
|
|
18683
|
+
projectName: u.projectName,
|
|
18682
18684
|
email: u.email,
|
|
18683
18685
|
accountId: u.accountId ?? void 0,
|
|
18684
18686
|
evmAddress: u.evmAddress,
|
|
@@ -18894,6 +18896,8 @@ function useVolrAuthCallback(options = {}) {
|
|
|
18894
18896
|
const toVolrUser = useCallback((u) => {
|
|
18895
18897
|
return {
|
|
18896
18898
|
id: u.id,
|
|
18899
|
+
projectId: u.projectId,
|
|
18900
|
+
projectName: u.projectName,
|
|
18897
18901
|
email: u.email,
|
|
18898
18902
|
accountId: u.accountId ?? void 0,
|
|
18899
18903
|
evmAddress: u.evmAddress,
|
|
@@ -19160,7 +19164,7 @@ async function enrollPasskey(params) {
|
|
|
19160
19164
|
userEvmAddress,
|
|
19161
19165
|
projectId,
|
|
19162
19166
|
rpId = typeof window !== "undefined" ? window.location.hostname : "localhost",
|
|
19163
|
-
rpName
|
|
19167
|
+
rpName
|
|
19164
19168
|
} = params;
|
|
19165
19169
|
if (!userId) {
|
|
19166
19170
|
throw new Error("userId is required");
|
|
@@ -19168,6 +19172,9 @@ async function enrollPasskey(params) {
|
|
|
19168
19172
|
if (!projectId) {
|
|
19169
19173
|
throw new Error("projectId is required");
|
|
19170
19174
|
}
|
|
19175
|
+
if (!rpName) {
|
|
19176
|
+
throw new Error("rpName is required");
|
|
19177
|
+
}
|
|
19171
19178
|
if (!baseUrl) {
|
|
19172
19179
|
throw new Error("baseUrl is required");
|
|
19173
19180
|
}
|
|
@@ -19318,7 +19325,17 @@ function usePasskeyEnrollment() {
|
|
|
19318
19325
|
"Access token is required for passkey enrollment. Please login first."
|
|
19319
19326
|
);
|
|
19320
19327
|
}
|
|
19321
|
-
|
|
19328
|
+
if (!user.projectId) {
|
|
19329
|
+
throw new Error(
|
|
19330
|
+
"Project ID is required for passkey enrollment. User data may be incomplete."
|
|
19331
|
+
);
|
|
19332
|
+
}
|
|
19333
|
+
if (!user.projectName) {
|
|
19334
|
+
throw new Error(
|
|
19335
|
+
"Project name is required for passkey enrollment. User data may be incomplete."
|
|
19336
|
+
);
|
|
19337
|
+
}
|
|
19338
|
+
const projectId = user.projectId;
|
|
19322
19339
|
setStep("encrypting");
|
|
19323
19340
|
const result = await enrollPasskey({
|
|
19324
19341
|
client,
|
|
@@ -19327,7 +19344,8 @@ function usePasskeyEnrollment() {
|
|
|
19327
19344
|
userId: user.id,
|
|
19328
19345
|
userEmail: user.email ?? null,
|
|
19329
19346
|
userEvmAddress: user.evmAddress ?? null,
|
|
19330
|
-
projectId
|
|
19347
|
+
projectId,
|
|
19348
|
+
rpName: user.projectName
|
|
19331
19349
|
});
|
|
19332
19350
|
setStep("registering");
|
|
19333
19351
|
if (typeof window !== "undefined") {
|
|
@@ -19335,7 +19353,7 @@ function usePasskeyEnrollment() {
|
|
|
19335
19353
|
}
|
|
19336
19354
|
const passkeyAdapter = createPasskeyAdapter({
|
|
19337
19355
|
rpId: typeof window !== "undefined" ? window.location.hostname : "localhost",
|
|
19338
|
-
rpName:
|
|
19356
|
+
rpName: user.projectName
|
|
19339
19357
|
});
|
|
19340
19358
|
const provider = createPasskeyProvider(passkeyAdapter, {
|
|
19341
19359
|
prfInput: result.prfInput,
|
|
@@ -19578,6 +19596,87 @@ async function uploadBlobViaPresign(params) {
|
|
|
19578
19596
|
}
|
|
19579
19597
|
return { s3Key };
|
|
19580
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
|
+
}
|
|
19581
19680
|
|
|
19582
19681
|
// src/utils/contract-analysis.ts
|
|
19583
19682
|
var EIP7702_PREFIX = "0xef0100";
|
|
@@ -20184,6 +20283,6 @@ async function getUserCredentials(client) {
|
|
|
20184
20283
|
(*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) *)
|
|
20185
20284
|
*/
|
|
20186
20285
|
|
|
20187
|
-
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 };
|
|
20188
20287
|
//# sourceMappingURL=index.js.map
|
|
20189
20288
|
//# sourceMappingURL=index.js.map
|