@volr/react-ui 0.2.5 → 0.2.6
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 +276 -250
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +34 -8
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import React15, { createContext, useContext, useState, useCallback, useEffect, useMemo, useRef, useId, useReducer } from 'react';
|
|
2
2
|
import { createPortal } from 'react-dom';
|
|
3
3
|
import { useVolrContext, useInternalAuth, usePasskeyEnrollment, checkPrfCompatibility, getPlatformHint, useMpcConnection, VolrProvider, useVolrAuthCallback, useVolrPaymentApi, completeMigration, requestMigration, decryptEntropyForMigration, listenForSeedRequests, useUserBalances, useVolrLogin, useVolr, useEIP6963, useWithdraw, useDepositListener, createGetNetworkInfo } from '@volr/react';
|
|
4
4
|
export { VolrProvider, useDepositListener, usePasskeyEnrollment, useVolr, useVolrLogin, useVolrPaymentApi } from '@volr/react';
|
|
@@ -1941,7 +1941,7 @@ var variantMap = {
|
|
|
1941
1941
|
ghost: { backgroundColor: "transparent", color: "var(--volr-text-secondary)", border: "none" },
|
|
1942
1942
|
outline: { backgroundColor: "transparent", color: "var(--volr-text-secondary)", border: "1px solid var(--volr-border)" }
|
|
1943
1943
|
};
|
|
1944
|
-
var Button =
|
|
1944
|
+
var Button = React15.forwardRef(
|
|
1945
1945
|
({ variant = "primary", size = "md", fullWidth, className, style, disabled, children, ...props }, ref) => {
|
|
1946
1946
|
const { accentColor } = useVolrUI();
|
|
1947
1947
|
const sizeStyle = sizeMap[size];
|
|
@@ -3785,7 +3785,7 @@ function AssetSelectView({
|
|
|
3785
3785
|
}) })
|
|
3786
3786
|
] });
|
|
3787
3787
|
}
|
|
3788
|
-
var TextLinkButton =
|
|
3788
|
+
var TextLinkButton = React15.forwardRef(({ showArrow = false, className, children, ...props }, ref) => {
|
|
3789
3789
|
return /* @__PURE__ */ jsxs(
|
|
3790
3790
|
"button",
|
|
3791
3791
|
{
|
|
@@ -5056,7 +5056,7 @@ function BalanceDetailView({
|
|
|
5056
5056
|
/* @__PURE__ */ jsx("div", { children: balances.map((token) => /* @__PURE__ */ jsx(TokenRow, { token }, token.id)) })
|
|
5057
5057
|
] });
|
|
5058
5058
|
}
|
|
5059
|
-
var Input =
|
|
5059
|
+
var Input = React15.forwardRef(
|
|
5060
5060
|
({ leftIcon, error, className, style, disabled, ...props }, ref) => {
|
|
5061
5061
|
return /* @__PURE__ */ jsxs("div", { className: "volr:relative", children: [
|
|
5062
5062
|
leftIcon && /* @__PURE__ */ jsx("div", { className: "volr:absolute volr:left-3 volr:top-1/2 volr:-translate-y-1/2 volr:pointer-events-none volr-text-muted", children: leftIcon }),
|
|
@@ -6486,6 +6486,7 @@ function usePaymentModalState(open, onOpenChange) {
|
|
|
6486
6486
|
if (!tokenInfo) {
|
|
6487
6487
|
return;
|
|
6488
6488
|
}
|
|
6489
|
+
const permitType = tokenInfo.permitType ?? (tokenInfo.permitSupported ? "EIP2612" : "NONE");
|
|
6489
6490
|
if (tokenInfo.address === "native") {
|
|
6490
6491
|
dispatch({
|
|
6491
6492
|
type: "PAYMENT_ERROR",
|
|
@@ -6496,6 +6497,16 @@ function usePaymentModalState(open, onOpenChange) {
|
|
|
6496
6497
|
});
|
|
6497
6498
|
return;
|
|
6498
6499
|
}
|
|
6500
|
+
if (permitType !== "EIP2612") {
|
|
6501
|
+
dispatch({
|
|
6502
|
+
type: "PAYMENT_ERROR",
|
|
6503
|
+
error: {
|
|
6504
|
+
code: "TOKEN_NOT_SUPPORTED",
|
|
6505
|
+
message: "External wallet payment is not supported for this token."
|
|
6506
|
+
}
|
|
6507
|
+
});
|
|
6508
|
+
return;
|
|
6509
|
+
}
|
|
6499
6510
|
dispatch({ type: "START_PAYMENT" });
|
|
6500
6511
|
let createdPaymentId = null;
|
|
6501
6512
|
const toPaymentError = (err) => {
|
|
@@ -7449,8 +7460,23 @@ var PaymentModal = ({
|
|
|
7449
7460
|
const requiresVolrWallet = config.walletPolicy?.requireVolrWalletOnLogin ?? true;
|
|
7450
7461
|
const hasVolrWallet = Boolean(user?.evmAddress);
|
|
7451
7462
|
const externalWalletAllowed = allowExternalWalletPayment && !requiresVolrWallet;
|
|
7452
|
-
const
|
|
7463
|
+
const resolvedPermitType = selectedToken?.permitType ?? (selectedToken?.permitSupported ? "EIP2612" : "NONE");
|
|
7464
|
+
const externalWalletTokenSupported = selectedToken && selectedToken.address !== "native" && resolvedPermitType === "EIP2612";
|
|
7453
7465
|
const showExternalWalletOption = externalWalletAllowed && externalWalletTokenSupported;
|
|
7466
|
+
const permit2WarnedRef = React15.useRef(false);
|
|
7467
|
+
React15.useEffect(() => {
|
|
7468
|
+
if (!permit2WarnedRef.current && externalWalletAllowed && resolvedPermitType === "PERMIT2" && !selectedToken?.permit2Address) {
|
|
7469
|
+
console.warn(
|
|
7470
|
+
`[volr/react-ui] External wallet payment hidden: permit2Address is not configured for chain ${selectedToken?.chainId}.`
|
|
7471
|
+
);
|
|
7472
|
+
permit2WarnedRef.current = true;
|
|
7473
|
+
}
|
|
7474
|
+
}, [
|
|
7475
|
+
externalWalletAllowed,
|
|
7476
|
+
resolvedPermitType,
|
|
7477
|
+
selectedToken?.permit2Address,
|
|
7478
|
+
selectedToken?.chainId
|
|
7479
|
+
]);
|
|
7454
7480
|
if (showDeposit && selectedToken) {
|
|
7455
7481
|
return /* @__PURE__ */ jsx(
|
|
7456
7482
|
DepositModal,
|
|
@@ -7920,7 +7946,7 @@ function WalletRequiredModal() {
|
|
|
7920
7946
|
}
|
|
7921
7947
|
);
|
|
7922
7948
|
}
|
|
7923
|
-
var VolrUIContext =
|
|
7949
|
+
var VolrUIContext = React15.createContext(null);
|
|
7924
7950
|
function getCurrentRpId() {
|
|
7925
7951
|
if (typeof window === "undefined") return "localhost";
|
|
7926
7952
|
return window.location.hostname;
|
|
@@ -8548,8 +8574,8 @@ function OnboardingChecker({
|
|
|
8548
8574
|
}) {
|
|
8549
8575
|
const { user, provider, isLoading } = useVolrContext();
|
|
8550
8576
|
const { isOpen: isModalOpen } = useVolrModal();
|
|
8551
|
-
const modalWasOpened =
|
|
8552
|
-
const pendingMismatchOnboarding =
|
|
8577
|
+
const modalWasOpened = React15.useRef(false);
|
|
8578
|
+
const pendingMismatchOnboarding = React15.useRef(false);
|
|
8553
8579
|
useEffect(() => {
|
|
8554
8580
|
if (isModalOpen) {
|
|
8555
8581
|
modalWasOpened.current = true;
|