@abstraxn/signer-react 1.0.7 → 1.0.9
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/CHANGELOG.md +22 -0
- package/dist/src/ConnectButton.css +1 -23
- package/dist/src/ConnectButton.d.ts +11 -1
- package/dist/src/ConnectButton.js +15 -8
- package/dist/src/ConnectButton.js.map +1 -1
- package/dist/src/components/AbstraxnProvider/AbstraxnProvider.js +5 -1
- package/dist/src/components/AbstraxnProvider/AbstraxnProvider.js.map +1 -1
- package/dist/src/components/AbstraxnProvider/AbstraxnProviderInner.d.ts +2 -1
- package/dist/src/components/AbstraxnProvider/AbstraxnProviderInner.js +108 -28
- package/dist/src/components/AbstraxnProvider/AbstraxnProviderInner.js.map +1 -1
- package/dist/src/components/AbstraxnProvider/AbstraxnProviderWithWagmi.js +3 -1
- package/dist/src/components/AbstraxnProvider/AbstraxnProviderWithWagmi.js.map +1 -1
- package/dist/src/hooks.js +30 -8
- package/dist/src/hooks.js.map +1 -1
- package/dist/src/types.d.ts +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,28 @@ All notable changes to this project will be documented in this file.
|
|
|
5
5
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|
6
6
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
7
|
|
|
8
|
+
## [1.0.9] - 2026-02-11
|
|
9
|
+
|
|
10
|
+
### Fixed
|
|
11
|
+
|
|
12
|
+
- **RPC URL when chain name is missing** – Building the default Ankr RPC URL now safely handles missing `viemChain.name` using optional chaining and nullish coalescing (`viemChain.name?.toLowerCase() ?? ""`) to avoid runtime errors.
|
|
13
|
+
|
|
14
|
+
- **“Connector not connected” / expired session** – When `signMessage`, `sendTransaction`, or `useWriteContract` hit a “Connector not connected” error (e.g. expired WalletConnect session), the SDK now attempts an internal reconnect via wagmi’s `useReconnect` and retries the operation once before asking the user to reconnect. This reduces unnecessary “Please reconnect your wallet” prompts when the session can be restored automatically.
|
|
15
|
+
|
|
16
|
+
- **useSwitchChain retry after user rejection** – If the user rejects the switch/add-chain dialog (e.g. cancels), the SDK no longer retries with the “add chain” flow. User rejection is detected via `UserRejectedRequestError`, error code 4001, or message containing “user rejected”/“cancelled”, and the error is rethrown immediately.
|
|
17
|
+
|
|
18
|
+
## [1.0.8] - 2026-02-09
|
|
19
|
+
|
|
20
|
+
### Added
|
|
21
|
+
|
|
22
|
+
- **ConnectButton** – New optional props `connectingText` and `disconnectingText` (defaults: `'Connecting...'`, `'Disconnecting...'`) to customize the label shown while connecting or disconnecting.
|
|
23
|
+
- **AbstraxnContextValue** – New `disconnecting` boolean in context so UI can show a dedicated disconnecting state (e.g. "Disconnecting..." on the connect button).
|
|
24
|
+
|
|
25
|
+
### Changed
|
|
26
|
+
|
|
27
|
+
- **ConnectButton loading state** – Button now shows text ("Connecting..." / "Disconnecting..."). The loading class is applied for both connecting and disconnecting; custom `children` are hidden while the button is busy.
|
|
28
|
+
- **WalletConnect reconnect** – When connecting again with WalletConnect, modal DOM nodes that were previously force-hidden after connection are reset (display style removed) so the QR modal can show again on reconnect.
|
|
29
|
+
|
|
8
30
|
## [1.0.4] - 2026-02-06
|
|
9
31
|
|
|
10
32
|
### Fixed
|
|
@@ -161,33 +161,11 @@
|
|
|
161
161
|
background: rgba(156, 163, 175, 0.2);
|
|
162
162
|
}
|
|
163
163
|
|
|
164
|
-
/* Loading State */
|
|
164
|
+
/* Loading State - show status text only (Connecting... / Disconnecting...) */
|
|
165
165
|
.abstraxn-connect-button-loading {
|
|
166
|
-
position: relative;
|
|
167
|
-
color: transparent !important;
|
|
168
166
|
pointer-events: none;
|
|
169
167
|
}
|
|
170
168
|
|
|
171
|
-
.abstraxn-connect-button-loading::after {
|
|
172
|
-
content: '';
|
|
173
|
-
position: absolute;
|
|
174
|
-
top: 50%;
|
|
175
|
-
left: 50%;
|
|
176
|
-
width: 16px;
|
|
177
|
-
height: 16px;
|
|
178
|
-
margin: -8px 0 0 -8px;
|
|
179
|
-
border: 2px solid currentColor;
|
|
180
|
-
border-top-color: transparent;
|
|
181
|
-
border-radius: 50%;
|
|
182
|
-
animation: spin 0.6s linear infinite;
|
|
183
|
-
}
|
|
184
|
-
|
|
185
|
-
@keyframes spin {
|
|
186
|
-
to {
|
|
187
|
-
transform: rotate(360deg);
|
|
188
|
-
}
|
|
189
|
-
}
|
|
190
|
-
|
|
191
169
|
/* Address Badge */
|
|
192
170
|
.abstraxn-connect-button-address {
|
|
193
171
|
display: inline-flex;
|
|
@@ -13,6 +13,16 @@ export interface ConnectButtonProps extends Omit<ButtonHTMLAttributes<HTMLButton
|
|
|
13
13
|
* @default 'Connected'
|
|
14
14
|
*/
|
|
15
15
|
connectedText?: string;
|
|
16
|
+
/**
|
|
17
|
+
* Custom button text when connecting
|
|
18
|
+
* @default 'Connecting...'
|
|
19
|
+
*/
|
|
20
|
+
connectingText?: string;
|
|
21
|
+
/**
|
|
22
|
+
* Custom button text when disconnecting
|
|
23
|
+
* @default 'Disconnecting...'
|
|
24
|
+
*/
|
|
25
|
+
disconnectingText?: string;
|
|
16
26
|
/**
|
|
17
27
|
* Show address when connected
|
|
18
28
|
* @default false
|
|
@@ -68,4 +78,4 @@ export interface ConnectButtonProps extends Omit<ButtonHTMLAttributes<HTMLButton
|
|
|
68
78
|
* }
|
|
69
79
|
* ```
|
|
70
80
|
*/
|
|
71
|
-
export declare function ConnectButton({ connectText, connectedText, showAddress, children, onClick, disabled, variant, size, className, style, disableDefaultStyles, ...props }: ConnectButtonProps): import("react/jsx-runtime").JSX.Element;
|
|
81
|
+
export declare function ConnectButton({ connectText, connectedText, connectingText, disconnectingText, showAddress, children, onClick, disabled, variant, size, className, style, disableDefaultStyles, ...props }: ConnectButtonProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -25,9 +25,10 @@ import './ConnectButton.css';
|
|
|
25
25
|
* }
|
|
26
26
|
* ```
|
|
27
27
|
*/
|
|
28
|
-
export function ConnectButton({ connectText = 'Connect Wallet', connectedText = 'Connected', showAddress = false, children, onClick, disabled, variant = 'primary', size = 'md', className = '', style, disableDefaultStyles = false, ...props }) {
|
|
29
|
-
const { isConnected, address, showOnboarding, loading, resending, uiConfig } = useAbstraxnWallet();
|
|
28
|
+
export function ConnectButton({ connectText = 'Connect Wallet', connectedText = 'Connected', connectingText = 'Connecting...', disconnectingText = 'Disconnecting...', showAddress = false, children, onClick, disabled, variant = 'primary', size = 'md', className = '', style, disableDefaultStyles = false, ...props }) {
|
|
29
|
+
const { isConnected, address, showOnboarding, loading, resending, disconnecting, uiConfig } = useAbstraxnWallet();
|
|
30
30
|
const showLoading = loading && !resending;
|
|
31
|
+
const isBusy = showLoading || (disconnecting ?? false);
|
|
31
32
|
const [isWalletModalOpen, setIsWalletModalOpen] = useState(false);
|
|
32
33
|
const handleClick = useCallback((e) => {
|
|
33
34
|
if (onClick) {
|
|
@@ -69,8 +70,8 @@ export function ConnectButton({ connectText = 'Connect Wallet', connectedText =
|
|
|
69
70
|
if (isConnected) {
|
|
70
71
|
classes.push('abstraxn-connect-button-connected');
|
|
71
72
|
}
|
|
72
|
-
// Loading state class
|
|
73
|
-
if (loading) {
|
|
73
|
+
// Loading state class (connecting or disconnecting)
|
|
74
|
+
if (loading || (disconnecting ?? false)) {
|
|
74
75
|
classes.push('abstraxn-connect-button-loading');
|
|
75
76
|
}
|
|
76
77
|
// Custom className
|
|
@@ -78,12 +79,18 @@ export function ConnectButton({ connectText = 'Connect Wallet', connectedText =
|
|
|
78
79
|
classes.push(className);
|
|
79
80
|
}
|
|
80
81
|
return classes.join(' ');
|
|
81
|
-
}, [disableDefaultStyles, isDark, size, variant, isConnected, showLoading, className]);
|
|
82
|
+
}, [disableDefaultStyles, isDark, size, variant, isConnected, showLoading, disconnecting, className]);
|
|
82
83
|
// Determine button content
|
|
83
84
|
const buttonContent = useMemo(() => {
|
|
84
|
-
if (children) {
|
|
85
|
+
if (children && !isBusy) {
|
|
85
86
|
return children;
|
|
86
87
|
}
|
|
88
|
+
if (disconnecting) {
|
|
89
|
+
return disconnectingText;
|
|
90
|
+
}
|
|
91
|
+
if (showLoading) {
|
|
92
|
+
return connectingText;
|
|
93
|
+
}
|
|
87
94
|
if (isConnected) {
|
|
88
95
|
if (showAddress && address) {
|
|
89
96
|
// Show shortened address
|
|
@@ -97,7 +104,7 @@ export function ConnectButton({ connectText = 'Connect Wallet', connectedText =
|
|
|
97
104
|
else {
|
|
98
105
|
return connectText;
|
|
99
106
|
}
|
|
100
|
-
}, [children, isConnected, showAddress, address, connectedText, connectText]);
|
|
101
|
-
return (_jsxs(_Fragment, { children: [_jsx("button", { ...props, className: buttonClasses, style: style, onClick: handleClick, disabled: disabled ||
|
|
107
|
+
}, [children, isBusy, disconnecting, showLoading, disconnectingText, connectingText, isConnected, showAddress, address, connectedText, connectText]);
|
|
108
|
+
return (_jsxs(_Fragment, { children: [_jsx("button", { ...props, className: buttonClasses, style: style, onClick: handleClick, disabled: disabled || isBusy, type: props.type || 'button', children: buttonContent }), isConnected && (_jsx(WalletModal, { isOpen: isWalletModalOpen, onClose: handleCloseModal }))] }));
|
|
102
109
|
}
|
|
103
110
|
//# sourceMappingURL=ConnectButton.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ConnectButton.js","sourceRoot":"","sources":["../../src/ConnectButton.tsx"],"names":[],"mappings":";AAAA;;;GAGG;AACH,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;AACvD,OAAO,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AACvD,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAE5C,OAAO,qBAAqB,CAAC;
|
|
1
|
+
{"version":3,"file":"ConnectButton.js","sourceRoot":"","sources":["../../src/ConnectButton.tsx"],"names":[],"mappings":";AAAA;;;GAGG;AACH,OAAO,E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AAC,IAAI,IAAI,QAAQ,YAE3B,aAAa,GACP,EACR,WAAW,IAAI,CACd,KAAC,WAAW,IAAC,MAAM,EAAE,iBAAiB,EAAE,OAAO,EAAE,gBAAgB,GAAI,CACtE,IACA,CACJ,CAAC;AACJ,CAAC"}
|
|
@@ -50,10 +50,14 @@ export function AbstraxnProvider({ config, children }) {
|
|
|
50
50
|
? viemChain.rpcUrls.public.http[0]
|
|
51
51
|
: viemChain.rpcUrls.public.http;
|
|
52
52
|
}
|
|
53
|
+
if (!rpcUrl || rpcUrl.trim() === "") {
|
|
54
|
+
const chainLabel = viemChain.name ?? viemChain.id ?? "unknown";
|
|
55
|
+
throw new Error(`No RPC URL configured for chain "${chainLabel}". Please provide an RPC URL for this chain (e.g. via rpcUrls.default.http or rpcUrls.public.http).`);
|
|
56
|
+
}
|
|
53
57
|
chains.push({
|
|
54
58
|
id: viemChain.id,
|
|
55
59
|
name: viemChain.name,
|
|
56
|
-
rpcUrl: rpcUrl
|
|
60
|
+
rpcUrl: rpcUrl,
|
|
57
61
|
nativeCurrency: viemChain.nativeCurrency,
|
|
58
62
|
});
|
|
59
63
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AbstraxnProvider.js","sourceRoot":"","sources":["../../../../src/components/AbstraxnProvider/AbstraxnProvider.tsx"],"names":[],"mappings":";AAAA;;;GAGG;AACH,OAAO,EAAE,OAAO,EAAkB,MAAM,OAAO,CAAC;AAChD,OAAO,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AACtC,OAAO,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AACtD,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AACvD,OAAO,EAAE,yBAAyB,EAAE,MAAM,6BAA6B,CAAC;AACxE,OAAO,EAAE,4BAA4B,EAAE,MAAM,gCAAgC,CAAC;AAC9E,OAAO,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,gBAAgB,EAAE,MAAM,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E;gBACzE,WAAW,UAAU,CAAC,MAAM,IAAI,SAAS,IAAI;gBAC7C,8FAA8F;gBAC9F,uCAAuC,CACxC,CAAC;YACF,OAAO,CACL,KAAC,4BAA4B,IAAC,MAAM,EAAE,MAAM,YACzC,QAAQ,GACoB,CAChC,CAAC;QACJ,CAAC;QAED,IAAI,WAAW,EAAE,CAAC;YAChB,OAAO,CAAC,KAAK,CAAC,gCAAgC,EAAE,WAAW,CAAC,CAAC;YAC7D,8DAA8D;YAC9D,OAAO,CACL,KAAC,4BAA4B,IAAC,MAAM,EAAE,MAAM,YACzC,QAAQ,GACoB,CAChC,CAAC;QACJ,CAAC;QAED,IAAI,CAAC,WAAW,EAAE,CAAC;YACjB,mDAAmD;YACnD,gEAAgE;YAChE,OAAO,CACL,KAAC,kBAAkB,IAAC,WAAW,EAAE,WAAW,YAC1C,cAAK,KAAK,EAAE,EAAE,OAAO,EAAE,MAAM,EAAE,6CAAoC,GAChD,CACtB,CAAC;QACJ,CAAC;QAED,iFAAiF;QACjF,iFAAiF;QACjF,OAAO,CACL,KAAC,kBAAkB,IAAC,WAAW,EAAE,WAAW,YAC1C,KAAC,aAAa,IACZ,MAAM,EAAE,WAAW,EACnB,YAAY,EAAE,MAAM,CAAC,YAAY,YAEjC,KAAC,yBAAyB,IAAC,MAAM,EAAE,MAAM,YACtC,QAAQ,GACiB,GACd,GACG,CACtB,CAAC;IACJ,CAAC;IAED,mEAAmE;IACnE,OAAO,CACL,KAAC,4BAA4B,IAAC,MAAM,EAAE,MAAM,YACzC,QAAQ,GACoB,CAChC,CAAC;AACJ,CAAC"}
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
*/
|
|
5
5
|
import { type ReactNode } from "react";
|
|
6
6
|
import type { AbstraxnProviderConfig } from "../../types";
|
|
7
|
-
import { useAccount, useConnect, useDisconnect, useSignMessage, useSendTransaction, useSwitchChain, useBalance } from "wagmi";
|
|
7
|
+
import { useAccount, useConnect, useDisconnect, useReconnect, useSignMessage, useSendTransaction, useSwitchChain, useBalance } from "wagmi";
|
|
8
8
|
import { useAbstraxnProviderBase } from "./useAbstraxnProviderBase";
|
|
9
9
|
interface AbstraxnProviderInnerProps {
|
|
10
10
|
config: AbstraxnProviderConfig;
|
|
@@ -14,6 +14,7 @@ interface AbstraxnProviderInnerProps {
|
|
|
14
14
|
wagmiAccount: ReturnType<typeof useAccount>;
|
|
15
15
|
wagmiConnect: ReturnType<typeof useConnect>;
|
|
16
16
|
wagmiDisconnect: ReturnType<typeof useDisconnect>;
|
|
17
|
+
wagmiReconnect: ReturnType<typeof useReconnect>;
|
|
17
18
|
wagmiSignMessage: ReturnType<typeof useSignMessage>;
|
|
18
19
|
wagmiSendTransaction: ReturnType<typeof useSendTransaction>;
|
|
19
20
|
wagmiSwitchChain: ReturnType<typeof useSwitchChain>;
|
|
@@ -21,6 +21,7 @@ export function AbstraxnProviderInner({ config, children, base, wagmi, }) {
|
|
|
21
21
|
const wagmiAccount = wagmi?.wagmiAccount || null;
|
|
22
22
|
const wagmiConnect = wagmi?.wagmiConnect || null;
|
|
23
23
|
const wagmiDisconnect = wagmi?.wagmiDisconnect || null;
|
|
24
|
+
const wagmiReconnect = wagmi?.wagmiReconnect || null;
|
|
24
25
|
const wagmiSignMessage = wagmi?.wagmiSignMessage || null;
|
|
25
26
|
const wagmiSendTransaction = wagmi?.wagmiSendTransaction || null;
|
|
26
27
|
const wagmiSwitchChain = wagmi?.wagmiSwitchChain || null;
|
|
@@ -32,6 +33,7 @@ export function AbstraxnProviderInner({ config, children, base, wagmi, }) {
|
|
|
32
33
|
const [externalWalletChainId, setExternalWalletChainId] = useState(null);
|
|
33
34
|
// Connection type tracking: 'google' | 'email' | 'discord' | 'x' | 'passkey' | 'metamask' | 'walletconnect' | 'coinbase' | 'phantom' | 'injected' | null
|
|
34
35
|
const [connectionType, setConnectionType] = useState(null);
|
|
36
|
+
const [disconnecting, setDisconnecting] = useState(false);
|
|
35
37
|
const explicitConnectionRef = useRef(false);
|
|
36
38
|
const autoDisconnectHandledRef = useRef(false);
|
|
37
39
|
// Track when we last connected to prevent premature reset
|
|
@@ -1282,6 +1284,7 @@ export function AbstraxnProviderInner({ config, children, base, wagmi, }) {
|
|
|
1282
1284
|
// Disconnect wallet
|
|
1283
1285
|
const disconnect = useCallback(async () => {
|
|
1284
1286
|
setLoading(true);
|
|
1287
|
+
setDisconnecting(true);
|
|
1285
1288
|
setError(null);
|
|
1286
1289
|
disconnectingRef.current = true; // Set flag to prevent useEffect from interfering
|
|
1287
1290
|
try {
|
|
@@ -1413,10 +1416,11 @@ export function AbstraxnProviderInner({ config, children, base, wagmi, }) {
|
|
|
1413
1416
|
}
|
|
1414
1417
|
finally {
|
|
1415
1418
|
// Clear disconnecting flag after a short delay to allow state to settle
|
|
1419
|
+
setDisconnecting(false);
|
|
1420
|
+
setLoading(false);
|
|
1416
1421
|
setTimeout(() => {
|
|
1417
1422
|
disconnectingRef.current = false;
|
|
1418
1423
|
}, 200);
|
|
1419
|
-
setLoading(false);
|
|
1420
1424
|
}
|
|
1421
1425
|
}, [isExternalWalletConnected, externalWalletsEnabled, wagmiDisconnect, wagmiAccount?.connector]);
|
|
1422
1426
|
// Hide onboarding UI
|
|
@@ -1509,6 +1513,22 @@ export function AbstraxnProviderInner({ config, children, base, wagmi, }) {
|
|
|
1509
1513
|
const isConnectorNotConnected = err?.name === "ConnectorNotConnectedError" ||
|
|
1510
1514
|
(typeof err?.message === "string" &&
|
|
1511
1515
|
err.message.includes("Connector not connected"));
|
|
1516
|
+
if (isConnectorNotConnected && wagmiReconnect?.mutateAsync) {
|
|
1517
|
+
try {
|
|
1518
|
+
await wagmiReconnect.mutateAsync({
|
|
1519
|
+
connectors: wagmiAccount?.connector
|
|
1520
|
+
? [wagmiAccount.connector]
|
|
1521
|
+
: undefined,
|
|
1522
|
+
});
|
|
1523
|
+
const signature = await wagmiSignMessage.signMessageAsync({
|
|
1524
|
+
message,
|
|
1525
|
+
});
|
|
1526
|
+
return signature;
|
|
1527
|
+
}
|
|
1528
|
+
catch (reconnectErr) {
|
|
1529
|
+
// Reconnect or retry failed, fall through to user-facing error
|
|
1530
|
+
}
|
|
1531
|
+
}
|
|
1512
1532
|
const error = isConnectorNotConnected
|
|
1513
1533
|
? new Error("Your wallet session expired or was disconnected. Please reconnect your wallet.")
|
|
1514
1534
|
: err instanceof Error
|
|
@@ -1531,7 +1551,13 @@ export function AbstraxnProviderInner({ config, children, base, wagmi, }) {
|
|
|
1531
1551
|
setError(err instanceof Error ? err : new Error("Failed to sign message"));
|
|
1532
1552
|
throw err;
|
|
1533
1553
|
}
|
|
1534
|
-
}, [
|
|
1554
|
+
}, [
|
|
1555
|
+
isExternalWalletConnected,
|
|
1556
|
+
externalWalletAddress,
|
|
1557
|
+
wagmiSignMessage,
|
|
1558
|
+
wagmiReconnect,
|
|
1559
|
+
wagmiAccount?.connector,
|
|
1560
|
+
]);
|
|
1535
1561
|
// Sign transaction
|
|
1536
1562
|
const signTransaction = useCallback(async (tx) => {
|
|
1537
1563
|
setError(null); // Clear any previous errors
|
|
@@ -1552,33 +1578,33 @@ export function AbstraxnProviderInner({ config, children, base, wagmi, }) {
|
|
|
1552
1578
|
if (isExternalWalletConnected &&
|
|
1553
1579
|
externalWalletAddress &&
|
|
1554
1580
|
wagmiSendTransaction) {
|
|
1581
|
+
// Convert TransactionRequest to wagmi format (shared for initial call and retry after reconnect)
|
|
1582
|
+
const wagmiTx = {
|
|
1583
|
+
to: tx.to,
|
|
1584
|
+
};
|
|
1585
|
+
if (tx.value) {
|
|
1586
|
+
wagmiTx.value =
|
|
1587
|
+
typeof tx.value === "string"
|
|
1588
|
+
? parseEther(tx.value)
|
|
1589
|
+
: BigInt(tx.value);
|
|
1590
|
+
}
|
|
1591
|
+
if (tx.data) {
|
|
1592
|
+
wagmiTx.data = tx.data;
|
|
1593
|
+
}
|
|
1594
|
+
if (tx.gasLimit) {
|
|
1595
|
+
wagmiTx.gas = tx.gasLimit;
|
|
1596
|
+
}
|
|
1597
|
+
if (tx.gasPrice) {
|
|
1598
|
+
wagmiTx.gasPrice = tx.gasPrice;
|
|
1599
|
+
}
|
|
1600
|
+
if (tx.maxFeePerGas) {
|
|
1601
|
+
wagmiTx.maxFeePerGas = tx.maxFeePerGas;
|
|
1602
|
+
}
|
|
1603
|
+
if (tx.maxPriorityFeePerGas) {
|
|
1604
|
+
wagmiTx.maxPriorityFeePerGas = tx.maxPriorityFeePerGas;
|
|
1605
|
+
}
|
|
1555
1606
|
try {
|
|
1556
1607
|
setLoading(true);
|
|
1557
|
-
// Convert TransactionRequest to wagmi format
|
|
1558
|
-
const wagmiTx = {
|
|
1559
|
-
to: tx.to,
|
|
1560
|
-
};
|
|
1561
|
-
if (tx.value) {
|
|
1562
|
-
wagmiTx.value =
|
|
1563
|
-
typeof tx.value === "string"
|
|
1564
|
-
? parseEther(tx.value)
|
|
1565
|
-
: BigInt(tx.value);
|
|
1566
|
-
}
|
|
1567
|
-
if (tx.data) {
|
|
1568
|
-
wagmiTx.data = tx.data;
|
|
1569
|
-
}
|
|
1570
|
-
if (tx.gasLimit) {
|
|
1571
|
-
wagmiTx.gas = tx.gasLimit;
|
|
1572
|
-
}
|
|
1573
|
-
if (tx.gasPrice) {
|
|
1574
|
-
wagmiTx.gasPrice = tx.gasPrice;
|
|
1575
|
-
}
|
|
1576
|
-
if (tx.maxFeePerGas) {
|
|
1577
|
-
wagmiTx.maxFeePerGas = tx.maxFeePerGas;
|
|
1578
|
-
}
|
|
1579
|
-
if (tx.maxPriorityFeePerGas) {
|
|
1580
|
-
wagmiTx.maxPriorityFeePerGas = tx.maxPriorityFeePerGas;
|
|
1581
|
-
}
|
|
1582
1608
|
const hash = await wagmiSendTransaction.sendTransactionAsync(wagmiTx);
|
|
1583
1609
|
return {
|
|
1584
1610
|
hash: hash,
|
|
@@ -1588,6 +1614,20 @@ export function AbstraxnProviderInner({ config, children, base, wagmi, }) {
|
|
|
1588
1614
|
const isConnectorNotConnected = err?.name === "ConnectorNotConnectedError" ||
|
|
1589
1615
|
(typeof err?.message === "string" &&
|
|
1590
1616
|
err.message.includes("Connector not connected"));
|
|
1617
|
+
if (isConnectorNotConnected && wagmiReconnect?.mutateAsync) {
|
|
1618
|
+
try {
|
|
1619
|
+
await wagmiReconnect.mutateAsync({
|
|
1620
|
+
connectors: wagmiAccount?.connector
|
|
1621
|
+
? [wagmiAccount.connector]
|
|
1622
|
+
: undefined,
|
|
1623
|
+
});
|
|
1624
|
+
const hash = await wagmiSendTransaction.sendTransactionAsync(wagmiTx);
|
|
1625
|
+
return { hash };
|
|
1626
|
+
}
|
|
1627
|
+
catch (reconnectErr) {
|
|
1628
|
+
// Reconnect or retry failed, fall through to user-facing error
|
|
1629
|
+
}
|
|
1630
|
+
}
|
|
1591
1631
|
const error = isConnectorNotConnected
|
|
1592
1632
|
? new Error("Your wallet session expired or was disconnected. Please reconnect your wallet.")
|
|
1593
1633
|
: err instanceof Error
|
|
@@ -1610,7 +1650,13 @@ export function AbstraxnProviderInner({ config, children, base, wagmi, }) {
|
|
|
1610
1650
|
setError(err instanceof Error ? err : new Error("Failed to send transaction"));
|
|
1611
1651
|
throw err;
|
|
1612
1652
|
}
|
|
1613
|
-
}, [
|
|
1653
|
+
}, [
|
|
1654
|
+
isExternalWalletConnected,
|
|
1655
|
+
externalWalletAddress,
|
|
1656
|
+
wagmiSendTransaction,
|
|
1657
|
+
wagmiReconnect,
|
|
1658
|
+
wagmiAccount?.connector,
|
|
1659
|
+
]);
|
|
1614
1660
|
// Sign transaction via API (returns signed transaction)
|
|
1615
1661
|
const signTransactionViaAPI = useCallback(async (unsignedTransaction, fromAddress) => {
|
|
1616
1662
|
if (!walletRef.current)
|
|
@@ -2136,6 +2182,39 @@ export function AbstraxnProviderInner({ config, children, base, wagmi, }) {
|
|
|
2136
2182
|
// This ensures that when we reconnect after a disconnect, the address change is detected
|
|
2137
2183
|
lastAddressRef.current = null;
|
|
2138
2184
|
lastChainIdRef.current = null;
|
|
2185
|
+
// For WalletConnect: reset any modal elements we previously force-hid after connection.
|
|
2186
|
+
// Otherwise on reconnect the same DOM nodes stay display:none and the QR never shows.
|
|
2187
|
+
const isWalletConnectConnector = connector &&
|
|
2188
|
+
(String(connector.id || "").toLowerCase().includes("walletconnect") ||
|
|
2189
|
+
String(connector.id || "").toLowerCase().includes("wallet_connect") ||
|
|
2190
|
+
String(connector.name || "").toLowerCase().includes("walletconnect"));
|
|
2191
|
+
if (isWalletConnectConnector && typeof document !== "undefined") {
|
|
2192
|
+
const wcModalSelectors = [
|
|
2193
|
+
"w3m-modal",
|
|
2194
|
+
"w3m-modal-backdrop",
|
|
2195
|
+
"[data-w3m-modal]",
|
|
2196
|
+
".w3m-modal",
|
|
2197
|
+
".w3m-modal-backdrop",
|
|
2198
|
+
"#w3m-modal",
|
|
2199
|
+
"[class*='w3m-modal']",
|
|
2200
|
+
"[id*='w3m-modal']",
|
|
2201
|
+
"[class*='walletconnect-qrcode']",
|
|
2202
|
+
"[id*='walletconnect']",
|
|
2203
|
+
];
|
|
2204
|
+
wcModalSelectors.forEach((sel) => {
|
|
2205
|
+
try {
|
|
2206
|
+
document.querySelectorAll(sel).forEach((el) => {
|
|
2207
|
+
const htmlEl = el;
|
|
2208
|
+
if (htmlEl?.style) {
|
|
2209
|
+
htmlEl.style.removeProperty("display");
|
|
2210
|
+
}
|
|
2211
|
+
});
|
|
2212
|
+
}
|
|
2213
|
+
catch {
|
|
2214
|
+
// Ignore
|
|
2215
|
+
}
|
|
2216
|
+
});
|
|
2217
|
+
}
|
|
2139
2218
|
try {
|
|
2140
2219
|
// Use connectAsync to properly await the connection
|
|
2141
2220
|
const result = await wagmiConnect.connectAsync({ connector });
|
|
@@ -2627,6 +2706,7 @@ export function AbstraxnProviderInner({ config, children, base, wagmi, }) {
|
|
|
2627
2706
|
error,
|
|
2628
2707
|
loading,
|
|
2629
2708
|
resending: resending ?? false,
|
|
2709
|
+
disconnecting: disconnecting ?? false,
|
|
2630
2710
|
init,
|
|
2631
2711
|
connect,
|
|
2632
2712
|
disconnect,
|