signer-test-sdk-react 0.0.11 → 0.0.13
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/README.md +1 -1
- package/dist/src/AbstraxnProvider.d.ts +2 -5
- package/dist/src/AbstraxnProvider.js +550 -50
- package/dist/src/AbstraxnProvider.js.map +1 -1
- package/dist/src/WalletModal.css +1973 -23
- package/dist/src/WalletModal.d.ts +2 -1
- package/dist/src/WalletModal.js +200 -30
- package/dist/src/WalletModal.js.map +1 -1
- package/dist/src/chains.d.ts +55 -0
- package/dist/src/chains.js +221 -0
- package/dist/src/chains.js.map +1 -0
- package/dist/src/components/OnboardingUI/OnboardingUIReact.js +24 -3
- package/dist/src/components/OnboardingUI/OnboardingUIReact.js.map +1 -1
- package/dist/src/components/OnboardingUI/OnboardingUIWeb.d.ts +11 -2
- package/dist/src/components/OnboardingUI/OnboardingUIWeb.js +266 -36
- package/dist/src/components/OnboardingUI/OnboardingUIWeb.js.map +1 -1
- package/dist/src/components/OnboardingUI/components/PasskeyButton.js +1 -1
- package/dist/src/components/OnboardingUI/components/PasskeyButton.js.map +1 -1
- package/dist/src/components/QRCode.d.ts +13 -0
- package/dist/src/components/QRCode.js +6 -0
- package/dist/src/components/QRCode.js.map +1 -0
- package/dist/src/components/WalletModal/components/ChainSelector.css +180 -0
- package/dist/src/components/WalletModal/components/ChainSelector.d.ts +10 -0
- package/dist/src/components/WalletModal/components/ChainSelector.js +34 -0
- package/dist/src/components/WalletModal/components/ChainSelector.js.map +1 -0
- package/dist/src/components/WalletModal/components/ExportKeyModal.css +133 -0
- package/dist/src/components/WalletModal/components/ExportKeyModal.d.ts +9 -0
- package/dist/src/components/WalletModal/components/ExportKeyModal.js +31 -0
- package/dist/src/components/WalletModal/components/ExportKeyModal.js.map +1 -0
- package/dist/src/components/WalletModal/components/ExportWarningModal.css +2 -0
- package/dist/src/components/WalletModal/components/ExportWarningModal.d.ts +11 -0
- package/dist/src/components/WalletModal/components/ExportWarningModal.js +18 -0
- package/dist/src/components/WalletModal/components/ExportWarningModal.js.map +1 -0
- package/dist/src/components/WalletModal/components/ManageWalletModal.css +160 -0
- package/dist/src/components/WalletModal/components/ManageWalletModal.d.ts +12 -0
- package/dist/src/components/WalletModal/components/ManageWalletModal.js +21 -0
- package/dist/src/components/WalletModal/components/ManageWalletModal.js.map +1 -0
- package/dist/src/components/WalletModal/components/PreviewTransactionModal.css +128 -0
- package/dist/src/components/WalletModal/components/PreviewTransactionModal.d.ts +17 -0
- package/dist/src/components/WalletModal/components/PreviewTransactionModal.js +10 -0
- package/dist/src/components/WalletModal/components/PreviewTransactionModal.js.map +1 -0
- package/dist/src/components/WalletModal/components/ReceiveModal.css +101 -0
- package/dist/src/components/WalletModal/components/ReceiveModal.d.ts +8 -0
- package/dist/src/components/WalletModal/components/ReceiveModal.js +22 -0
- package/dist/src/components/WalletModal/components/ReceiveModal.js.map +1 -0
- package/dist/src/components/WalletModal/components/SendModal.css +234 -0
- package/dist/src/components/WalletModal/components/SendModal.d.ts +18 -0
- package/dist/src/components/WalletModal/components/SendModal.js +127 -0
- package/dist/src/components/WalletModal/components/SendModal.js.map +1 -0
- package/dist/src/components/WalletModal/components/SuccessModal.css +86 -0
- package/dist/src/components/WalletModal/components/SuccessModal.d.ts +13 -0
- package/dist/src/components/WalletModal/components/SuccessModal.js +8 -0
- package/dist/src/components/WalletModal/components/SuccessModal.js.map +1 -0
- package/dist/src/components/WalletModal/components/UserAvatar.d.ts +9 -0
- package/dist/src/components/WalletModal/components/UserAvatar.js +31 -0
- package/dist/src/components/WalletModal/components/UserAvatar.js.map +1 -0
- package/dist/src/components/WalletModal/components/index.d.ts +21 -0
- package/dist/src/components/WalletModal/components/index.js +13 -0
- package/dist/src/components/WalletModal/components/index.js.map +1 -0
- package/dist/src/components/WalletModal/hooks/index.d.ts +6 -0
- package/dist/src/components/WalletModal/hooks/index.js +7 -0
- package/dist/src/components/WalletModal/hooks/index.js.map +1 -0
- package/dist/src/components/WalletModal/hooks/useAddressValidation.d.ts +4 -0
- package/dist/src/components/WalletModal/hooks/useAddressValidation.js +17 -0
- package/dist/src/components/WalletModal/hooks/useAddressValidation.js.map +1 -0
- package/dist/src/components/WalletModal/hooks/useAmountValidation.d.ts +4 -0
- package/dist/src/components/WalletModal/hooks/useAmountValidation.js +29 -0
- package/dist/src/components/WalletModal/hooks/useAmountValidation.js.map +1 -0
- package/dist/src/components/WalletModal/hooks/useSendTransaction.d.ts +20 -0
- package/dist/src/components/WalletModal/hooks/useSendTransaction.js +55 -0
- package/dist/src/components/WalletModal/hooks/useSendTransaction.js.map +1 -0
- package/dist/src/components/WalletModal/index.d.ts +5 -0
- package/dist/src/components/WalletModal/index.js +7 -0
- package/dist/src/components/WalletModal/index.js.map +1 -0
- package/dist/src/components/WalletModal/utils/addressUtils.d.ts +19 -0
- package/dist/src/components/WalletModal/utils/addressUtils.js +62 -0
- package/dist/src/components/WalletModal/utils/addressUtils.js.map +1 -0
- package/dist/src/components/WalletModal/utils/formatUtils.d.ts +20 -0
- package/dist/src/components/WalletModal/utils/formatUtils.js +47 -0
- package/dist/src/components/WalletModal/utils/formatUtils.js.map +1 -0
- package/dist/src/components/WalletModal/utils/index.d.ts +5 -0
- package/dist/src/components/WalletModal/utils/index.js +6 -0
- package/dist/src/components/WalletModal/utils/index.js.map +1 -0
- package/dist/src/index.d.ts +2 -1
- package/dist/src/index.js +1 -0
- package/dist/src/index.js.map +1 -1
- package/dist/src/types.d.ts +29 -0
- package/dist/src/wagmiConfig.js +6 -2
- package/dist/src/wagmiConfig.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +8 -8
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import './SuccessModal.css';
|
|
3
|
+
export function SuccessModal({ isOpen, onClose, txHash, currentChain, theme = 'dark', }) {
|
|
4
|
+
if (!isOpen)
|
|
5
|
+
return null;
|
|
6
|
+
return (_jsx("div", { className: `wallet-modal-overlay wallet-modal-theme-${theme}`, onClick: onClose, children: _jsx("div", { className: `wallet-modal-content wallet-modal-theme-${theme} wallet-modal-success`, onClick: (e) => e.stopPropagation(), children: _jsxs("div", { className: "wallet-modal-success-content", children: [_jsx("div", { className: "wallet-modal-success-icon", children: _jsxs("svg", { width: "64", height: "64", viewBox: "0 0 64 64", fill: "none", children: [_jsx("circle", { cx: "32", cy: "32", r: "32", fill: "#10b981" }), _jsx("path", { d: "M20 32L28 40L44 24", stroke: "white", strokeWidth: "4", strokeLinecap: "round", strokeLinejoin: "round" })] }) }), _jsx("h2", { className: "wallet-modal-success-title", children: "Transaction Sent!" }), _jsx("p", { className: "wallet-modal-success-message", children: "Your transaction has been submitted successfully." }), currentChain?.blockExplorer && (_jsxs("a", { href: `${currentChain.blockExplorer.url}/tx/${txHash}`, target: "_blank", rel: "noopener noreferrer", className: `wallet-modal-success-link wallet-modal-theme-${theme}`, children: ["View on ", currentChain.blockExplorer.name] })), _jsx("button", { className: `wallet-modal-success-btn wallet-modal-theme-${theme}`, onClick: onClose, children: "Done" })] }) }) }));
|
|
7
|
+
}
|
|
8
|
+
//# sourceMappingURL=SuccessModal.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SuccessModal.js","sourceRoot":"","sources":["../../../../../src/components/WalletModal/components/SuccessModal.tsx"],"names":[],"mappings":";AAIA,OAAO,oBAAoB,CAAC;AAU5B,MAAM,UAAU,YAAY,CAAC,EAC3B,MAAM,EACN,OAAO,EACP,MAAM,EACN,YAAY,EACZ,KAAK,GAAG,MAAM,GACI;IAClB,IAAI,CAAC,MAAM;QAAE,OAAO,IAAI,CAAC;IAEzB,OAAO,CACL,cACE,SAAS,EAAE,2CAA2C,KAAK,EAAE,EAC7D,OAAO,EAAE,OAAO,YAEhB,cACE,SAAS,EAAE,2CAA2C,KAAK,uBAAuB,EAClF,OAAO,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,eAAe,EAAE,YAEnC,eAAK,SAAS,EAAC,8BAA8B,aAC3C,cAAK,SAAS,EAAC,2BAA2B,YACxC,eAAK,KAAK,EAAC,IAAI,EAAC,MAAM,EAAC,IAAI,EAAC,OAAO,EAAC,WAAW,EAAC,IAAI,EAAC,MAAM,aACzD,iBAAQ,EAAE,EAAC,IAAI,EAAC,EAAE,EAAC,IAAI,EAAC,CAAC,EAAC,IAAI,EAAC,IAAI,EAAC,SAAS,GAAG,EAChD,eACE,CAAC,EAAC,oBAAoB,EACtB,MAAM,EAAC,OAAO,EACd,WAAW,EAAC,GAAG,EACf,aAAa,EAAC,OAAO,EACrB,cAAc,EAAC,OAAO,GACtB,IACE,GACF,EACN,aAAI,SAAS,EAAC,4BAA4B,kCAAuB,EACjE,YAAG,SAAS,EAAC,8BAA8B,kEAEvC,EACH,YAAY,EAAE,aAAa,IAAI,CAC9B,aACE,IAAI,EAAE,GAAG,YAAY,CAAC,aAAa,CAAC,GAAG,OAAO,MAAM,EAAE,EACtD,MAAM,EAAC,QAAQ,EACf,GAAG,EAAC,qBAAqB,EACzB,SAAS,EAAE,gDAAgD,KAAK,EAAE,yBAEzD,YAAY,CAAC,aAAa,CAAC,IAAI,IACtC,CACL,EACD,iBACE,SAAS,EAAE,+CAA+C,KAAK,EAAE,EACjE,OAAO,EAAE,OAAO,qBAGT,IACL,GACF,GACF,CACP,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* User Avatar Component
|
|
3
|
+
*/
|
|
4
|
+
import type { User } from 'signer-test-sdk-core';
|
|
5
|
+
export interface UserAvatarProps {
|
|
6
|
+
user: User | null;
|
|
7
|
+
isExternalWalletConnected: boolean;
|
|
8
|
+
}
|
|
9
|
+
export declare function UserAvatar({ user, isExternalWalletConnected }: UserAvatarProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
export function UserAvatar({ user, isExternalWalletConnected }) {
|
|
3
|
+
const authProvider = (user?.authProvider || '').toLowerCase();
|
|
4
|
+
// External wallet
|
|
5
|
+
if (isExternalWalletConnected) {
|
|
6
|
+
return (_jsxs("svg", { width: "32", height: "32", viewBox: "0 0 24 24", fill: "none", children: [_jsx("path", { d: "M12 2L2 7L12 12L22 7L12 2Z", fill: "white" }), _jsx("path", { d: "M2 17L12 22L22 17M2 12L12 17L22 12", stroke: "white", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round" })] }));
|
|
7
|
+
}
|
|
8
|
+
// Google
|
|
9
|
+
if (authProvider === 'google') {
|
|
10
|
+
return (_jsxs("svg", { width: "32", height: "32", viewBox: "0 0 24 24", fill: "none", children: [_jsx("path", { d: "M22.56 12.25c0-.78-.07-1.53-.2-2.25H12v4.26h5.92c-.26 1.37-1.04 2.53-2.21 3.31v2.77h3.57c2.08-1.92 3.28-4.74 3.28-8.09z", fill: "#4285F4" }), _jsx("path", { d: "M12 23c2.97 0 5.46-.98 7.28-2.66l-3.57-2.77c-.98.66-2.23 1.06-3.71 1.06-2.86 0-5.29-1.93-6.16-4.53H2.18v2.84C3.99 20.53 7.7 23 12 23z", fill: "#34A853" }), _jsx("path", { d: "M5.84 14.09c-.22-.66-.35-1.36-.35-2.09s.13-1.43.35-2.09V7.07H2.18C1.43 8.55 1 10.22 1 12s.43 3.45 1.18 4.93l2.85-2.22.81-.62z", fill: "#FBBC05" }), _jsx("path", { d: "M12 5.38c1.62 0 3.06.56 4.21 1.64l3.15-3.15C17.45 2.09 14.97 1 12 1 7.7 1 3.99 3.47 2.18 7.07l3.66 2.84c.87-2.6 3.3-4.53 6.16-4.53z", fill: "#EA4335" })] }));
|
|
11
|
+
}
|
|
12
|
+
// Discord
|
|
13
|
+
if (authProvider === 'discord') {
|
|
14
|
+
return (_jsx("svg", { width: "32", height: "32", viewBox: "0 0 24 24", fill: "none", children: _jsx("path", { d: "M20.317 4.37a19.791 19.791 0 0 0-4.885-1.515.074.074 0 0 0-.079.037c-.21.375-.444.864-.608 1.25a18.27 18.27 0 0 0-5.487 0 12.64 12.64 0 0 0-.617-1.25.077.077 0 0 0-.079-.037A19.736 19.736 0 0 0 3.677 4.37a.07.07 0 0 0-.032.027C2.451 6.018 1.9 7.765 1.6 9.515a.082.082 0 0 0 .031.084 19.9 19.9 0 0 0 5.993 3.03.078.078 0 0 0 .084-.028c.462-.63.874-1.295 1.226-1.994a.076.076 0 0 0-.041-.106 13.107 13.107 0 0 1-1.872-.892.077.077 0 0 1-.008-.128 10.2 10.2 0 0 0 .372-.292.074.074 0 0 1 .077-.01c3.928 1.793 8.18 1.793 12.062 0a.074.074 0 0 1 .078.01c.12.098.246.198.373.292a.077.077 0 0 1-.006.127 12.299 12.299 0 0 1-1.873.892.077.077 0 0 0-.041.107c.36.698.772 1.362 1.225 1.993a.076.076 0 0 0 .084.028 19.839 19.839 0 0 0 6.002-3.03.077.077 0 0 0 .032-.084c-.334-1.847-.93-3.591-1.679-5.118a.061.061 0 0 0-.031-.03zM8.02 15.33c-1.183 0-2.157-1.085-2.157-2.419 0-1.333.956-2.419 2.157-2.419 1.21 0 2.176 1.096 2.157 2.42 0 1.333-.956 2.418-2.157 2.418zm7.975 0c-1.183 0-2.157-1.085-2.157-2.419 0-1.333.955-2.419 2.157-2.419 1.21 0 2.176 1.096 2.157 2.42 0 1.333-.946 2.418-2.157 2.418z", fill: "#5865F2" }) }));
|
|
15
|
+
}
|
|
16
|
+
// Twitter/X
|
|
17
|
+
if (authProvider === 'twitter' || authProvider === 'x') {
|
|
18
|
+
return (_jsx("svg", { width: "32", height: "32", viewBox: "0 0 24 24", fill: "none", children: _jsx("path", { d: "M18.244 2.25h3.308l-7.227 8.26 8.502 11.24H16.17l-5.214-6.817L4.99 21.75H1.68l7.73-8.835L1.254 2.25H8.08l4.713 6.231zm-1.161 17.52h1.833L7.084 4.126H5.117z", fill: "white" }) }));
|
|
19
|
+
}
|
|
20
|
+
// Passkey/WebAuthn
|
|
21
|
+
if (authProvider === 'passkey' || authProvider === 'webauthn') {
|
|
22
|
+
return (_jsx("svg", { width: "32", height: "32", viewBox: "0 0 24 24", fill: "none", children: _jsx("path", { d: "M12 2C8.13 2 5 5.13 5 9C5 14.25 12 22 12 22C12 22 19 14.25 19 9C19 5.13 15.87 2 12 2ZM12 11.5C10.62 11.5 9.5 10.38 9.5 9C9.5 7.62 10.62 6.5 12 6.5C13.38 6.5 14.5 7.62 14.5 9C14.5 10.38 13.38 11.5 12 11.5Z", fill: "white" }) }));
|
|
23
|
+
}
|
|
24
|
+
// Email/OTP
|
|
25
|
+
if (user?.email && (!authProvider || authProvider === 'otp' || authProvider === 'email')) {
|
|
26
|
+
return (_jsxs("svg", { width: "32", height: "32", viewBox: "0 0 24 24", fill: "none", children: [_jsx("path", { d: "M4 4H20C21.1 4 22 4.9 22 6V18C22 19.1 21.1 20 20 20H4C2.9 20 2 19.1 2 18V6C2 4.9 2.9 4 4 4Z", stroke: "white", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round" }), _jsx("path", { d: "M22 6L12 13L2 6", stroke: "white", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round" })] }));
|
|
27
|
+
}
|
|
28
|
+
// Default fallback
|
|
29
|
+
return (_jsxs("svg", { width: "32", height: "32", viewBox: "0 0 24 24", fill: "none", children: [_jsx("path", { d: "M12 12C14.21 12 16 10.21 16 8C16 5.79 14.21 4 12 4C9.79 4 8 5.79 8 8C8 10.21 9.79 12 12 12Z", fill: "white" }), _jsx("path", { d: "M12 14C7.58 14 4 15.79 4 18V20H20V18C20 15.79 16.42 14 12 14Z", fill: "white" })] }));
|
|
30
|
+
}
|
|
31
|
+
//# sourceMappingURL=UserAvatar.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"UserAvatar.js","sourceRoot":"","sources":["../../../../../src/components/WalletModal/components/UserAvatar.tsx"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AM,aACvD,eACE,CAAC,EAAC,6FAA6F,EAC/F,IAAI,EAAC,OAAO,GACZ,EACF,eACE,CAAC,EAAC,+DAA+D,EACjE,IAAI,EAAC,OAAO,GACZ,IACE,CACT,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WalletModal Components
|
|
3
|
+
*/
|
|
4
|
+
export { ChainSelector } from './ChainSelector';
|
|
5
|
+
export { SendModal } from './SendModal';
|
|
6
|
+
export { ReceiveModal } from './ReceiveModal';
|
|
7
|
+
export { ManageWalletModal } from './ManageWalletModal';
|
|
8
|
+
export { PreviewTransactionModal } from './PreviewTransactionModal';
|
|
9
|
+
export { SuccessModal } from './SuccessModal';
|
|
10
|
+
export { ExportWarningModal } from './ExportWarningModal';
|
|
11
|
+
export { ExportKeyModal } from './ExportKeyModal';
|
|
12
|
+
export { UserAvatar } from './UserAvatar';
|
|
13
|
+
export type { ChainSelectorProps } from './ChainSelector';
|
|
14
|
+
export type { SendModalProps } from './SendModal';
|
|
15
|
+
export type { ReceiveModalProps } from './ReceiveModal';
|
|
16
|
+
export type { ManageWalletModalProps } from './ManageWalletModal';
|
|
17
|
+
export type { PreviewTransactionModalProps } from './PreviewTransactionModal';
|
|
18
|
+
export type { SuccessModalProps } from './SuccessModal';
|
|
19
|
+
export type { ExportWarningModalProps } from './ExportWarningModal';
|
|
20
|
+
export type { ExportKeyModalProps } from './ExportKeyModal';
|
|
21
|
+
export type { UserAvatarProps } from './UserAvatar';
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WalletModal Components
|
|
3
|
+
*/
|
|
4
|
+
export { ChainSelector } from './ChainSelector';
|
|
5
|
+
export { SendModal } from './SendModal';
|
|
6
|
+
export { ReceiveModal } from './ReceiveModal';
|
|
7
|
+
export { ManageWalletModal } from './ManageWalletModal';
|
|
8
|
+
export { PreviewTransactionModal } from './PreviewTransactionModal';
|
|
9
|
+
export { SuccessModal } from './SuccessModal';
|
|
10
|
+
export { ExportWarningModal } from './ExportWarningModal';
|
|
11
|
+
export { ExportKeyModal } from './ExportKeyModal';
|
|
12
|
+
export { UserAvatar } from './UserAvatar';
|
|
13
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/components/WalletModal/components/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,EAAE,uBAAuB,EAAE,MAAM,2BAA2B,CAAC;AACpE,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAC1D,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/components/WalletModal/hooks/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAC9D,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAC5D,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Hook for address validation
|
|
3
|
+
*/
|
|
4
|
+
import { useCallback } from 'react';
|
|
5
|
+
import { validateRecipientAddress } from '../utils/addressUtils';
|
|
6
|
+
export function useAddressValidation(senderAddress, currentChain) {
|
|
7
|
+
const validate = useCallback((address) => {
|
|
8
|
+
if (!currentChain) {
|
|
9
|
+
return 'Chain not selected';
|
|
10
|
+
}
|
|
11
|
+
const chainType = currentChain.type || 'evm';
|
|
12
|
+
const result = validateRecipientAddress(address, senderAddress, chainType);
|
|
13
|
+
return result.error;
|
|
14
|
+
}, [senderAddress, currentChain]);
|
|
15
|
+
return { validate };
|
|
16
|
+
}
|
|
17
|
+
//# sourceMappingURL=useAddressValidation.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useAddressValidation.js","sourceRoot":"","sources":["../../../../../src/components/WalletModal/hooks/useAddressValidation.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,EAAE,WAAW,EAAE,MAAM,OAAO,CAAC;AACpC,OAAO,EAAE,wBAAwB,EAAE,MAAM,uBAAuB,CAAC;AAGjE,MAAM,UAAU,oBAAoB,CAClC,aAAwC,EACxC,YAA0C;IAE1C,MAAM,QAAQ,GAAG,WAAW,CAC1B,CAAC,OAAe,EAAU,EAAE;QAC1B,IAAI,CAAC,YAAY,EAAE,CAAC;YAClB,OAAO,oBAAoB,CAAC;QAC9B,CAAC;QAED,MAAM,SAAS,GAAG,YAAY,CAAC,IAAI,IAAI,KAAK,CAAC;QAC7C,MAAM,MAAM,GAAG,wBAAwB,CAAC,OAAO,EAAE,aAAa,EAAE,SAAS,CAAC,CAAC;QAC3E,OAAO,MAAM,CAAC,KAAK,CAAC;IACtB,CAAC,EACD,CAAC,aAAa,EAAE,YAAY,CAAC,CAC9B,CAAC;IAEF,OAAO,EAAE,QAAQ,EAAE,CAAC;AACtB,CAAC"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Hook for amount validation
|
|
3
|
+
*/
|
|
4
|
+
import { useCallback } from 'react';
|
|
5
|
+
export function useAmountValidation(availableBalance, currentChain) {
|
|
6
|
+
const validate = useCallback((amount) => {
|
|
7
|
+
if (!amount || amount.trim() === '') {
|
|
8
|
+
return 'Amount is required';
|
|
9
|
+
}
|
|
10
|
+
const numAmount = parseFloat(amount);
|
|
11
|
+
if (isNaN(numAmount) || numAmount <= 0) {
|
|
12
|
+
return 'Amount must be greater than 0';
|
|
13
|
+
}
|
|
14
|
+
if (!availableBalance || availableBalance === 0n) {
|
|
15
|
+
return 'Insufficient balance';
|
|
16
|
+
}
|
|
17
|
+
if (!currentChain) {
|
|
18
|
+
return 'Chain not selected';
|
|
19
|
+
}
|
|
20
|
+
const decimals = currentChain.nativeCurrency.decimals;
|
|
21
|
+
const availableBalanceValue = Number(availableBalance) / Math.pow(10, decimals);
|
|
22
|
+
if (numAmount > availableBalanceValue) {
|
|
23
|
+
return `Insufficient balance. Available: ${availableBalanceValue.toFixed(6)} ${currentChain.nativeCurrency.symbol}`;
|
|
24
|
+
}
|
|
25
|
+
return '';
|
|
26
|
+
}, [availableBalance, currentChain]);
|
|
27
|
+
return { validate };
|
|
28
|
+
}
|
|
29
|
+
//# sourceMappingURL=useAmountValidation.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useAmountValidation.js","sourceRoot":"","sources":["../../../../../src/components/WalletModal/hooks/useAmountValidation.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,EAAE,WAAW,EAAE,MAAM,OAAO,CAAC;AAGpC,MAAM,UAAU,mBAAmB,CACjC,gBAA2C,EAC3C,YAA0C;IAE1C,MAAM,QAAQ,GAAG,WAAW,CAC1B,CAAC,MAAc,EAAU,EAAE;QACzB,IAAI,CAAC,MAAM,IAAI,MAAM,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE,CAAC;YACpC,OAAO,oBAAoB,CAAC;QAC9B,CAAC;QAED,MAAM,SAAS,GAAG,UAAU,CAAC,MAAM,CAAC,CAAC;QACrC,IAAI,KAAK,CAAC,SAAS,CAAC,IAAI,SAAS,IAAI,CAAC,EAAE,CAAC;YACvC,OAAO,+BAA+B,CAAC;QACzC,CAAC;QAED,IAAI,CAAC,gBAAgB,IAAI,gBAAgB,KAAK,EAAE,EAAE,CAAC;YACjD,OAAO,sBAAsB,CAAC;QAChC,CAAC;QAED,IAAI,CAAC,YAAY,EAAE,CAAC;YAClB,OAAO,oBAAoB,CAAC;QAC9B,CAAC;QAED,MAAM,QAAQ,GAAG,YAAY,CAAC,cAAc,CAAC,QAAQ,CAAC;QACtD,MAAM,qBAAqB,GAAG,MAAM,CAAC,gBAAgB,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,EAAE,EAAE,QAAQ,CAAC,CAAC;QAEhF,IAAI,SAAS,GAAG,qBAAqB,EAAE,CAAC;YACtC,OAAO,oCAAoC,qBAAqB,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI,YAAY,CAAC,cAAc,CAAC,MAAM,EAAE,CAAC;QACtH,CAAC;QAED,OAAO,EAAE,CAAC;IACZ,CAAC,EACD,CAAC,gBAAgB,EAAE,YAAY,CAAC,CACjC,CAAC;IAEF,OAAO,EAAE,QAAQ,EAAE,CAAC;AACtB,CAAC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { TransactionRequest } from 'signer-test-sdk-core';
|
|
2
|
+
import type { ChainData } from '../../../chains';
|
|
3
|
+
interface UseSendTransactionProps {
|
|
4
|
+
sendTransaction?: (tx: TransactionRequest) => Promise<{
|
|
5
|
+
hash: string;
|
|
6
|
+
}>;
|
|
7
|
+
currentChain: ChainData | null | undefined;
|
|
8
|
+
fromAddress?: string | null;
|
|
9
|
+
onSuccess?: (txHash: string) => void;
|
|
10
|
+
onError?: (error: Error) => void;
|
|
11
|
+
}
|
|
12
|
+
export declare function useSendTransaction({ sendTransaction, currentChain, fromAddress, onSuccess, onError, }: UseSendTransactionProps): {
|
|
13
|
+
send: (recipientAddress: string, amount: string) => Promise<{
|
|
14
|
+
hash: string;
|
|
15
|
+
}>;
|
|
16
|
+
isSending: boolean;
|
|
17
|
+
txHash: string | null;
|
|
18
|
+
reset: () => void;
|
|
19
|
+
};
|
|
20
|
+
export {};
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Hook for managing send transaction state and logic
|
|
3
|
+
*/
|
|
4
|
+
import { useState, useCallback } from 'react';
|
|
5
|
+
import { amountToSmallestUnit } from '../utils/formatUtils';
|
|
6
|
+
export function useSendTransaction({ sendTransaction, currentChain, fromAddress, onSuccess, onError, }) {
|
|
7
|
+
const [isSending, setIsSending] = useState(false);
|
|
8
|
+
const [txHash, setTxHash] = useState(null);
|
|
9
|
+
const send = useCallback(async (recipientAddress, amount) => {
|
|
10
|
+
if (!sendTransaction || !currentChain) {
|
|
11
|
+
throw new Error('Transaction not available');
|
|
12
|
+
}
|
|
13
|
+
if (!fromAddress) {
|
|
14
|
+
throw new Error('Sender address is required');
|
|
15
|
+
}
|
|
16
|
+
// For Solana, we might need different handling
|
|
17
|
+
if (currentChain.type === 'solana') {
|
|
18
|
+
throw new Error('Solana transactions are not yet supported. Please use EVM chains.');
|
|
19
|
+
}
|
|
20
|
+
setIsSending(true);
|
|
21
|
+
try {
|
|
22
|
+
const decimals = currentChain.nativeCurrency.decimals;
|
|
23
|
+
const amountInSmallestUnit = amountToSmallestUnit(amount, decimals);
|
|
24
|
+
const tx = {
|
|
25
|
+
from: fromAddress,
|
|
26
|
+
to: recipientAddress,
|
|
27
|
+
value: amountInSmallestUnit.toString(),
|
|
28
|
+
chainId: currentChain.id,
|
|
29
|
+
};
|
|
30
|
+
const result = await sendTransaction(tx);
|
|
31
|
+
setTxHash(result.hash);
|
|
32
|
+
onSuccess?.(result.hash);
|
|
33
|
+
return result;
|
|
34
|
+
}
|
|
35
|
+
catch (error) {
|
|
36
|
+
const err = error instanceof Error ? error : new Error('Failed to send transaction');
|
|
37
|
+
onError?.(err);
|
|
38
|
+
throw err;
|
|
39
|
+
}
|
|
40
|
+
finally {
|
|
41
|
+
setIsSending(false);
|
|
42
|
+
}
|
|
43
|
+
}, [sendTransaction, currentChain, fromAddress, onSuccess, onError]);
|
|
44
|
+
const reset = useCallback(() => {
|
|
45
|
+
setTxHash(null);
|
|
46
|
+
setIsSending(false);
|
|
47
|
+
}, []);
|
|
48
|
+
return {
|
|
49
|
+
send,
|
|
50
|
+
isSending,
|
|
51
|
+
txHash,
|
|
52
|
+
reset,
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
//# sourceMappingURL=useSendTransaction.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useSendTransaction.js","sourceRoot":"","sources":["../../../../../src/components/WalletModal/hooks/useSendTransaction.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,EAAE,QAAQ,EAAE,WAAW,EAAa,MAAM,OAAO,CAAC;AAGzD,OAAO,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AAU5D,MAAM,UAAU,kBAAkB,CAAC,EACjC,eAAe,EACf,YAAY,EACZ,WAAW,EACX,SAAS,EACT,OAAO,GACiB;IACxB,MAAM,CAAC,SAAS,EAAE,YAAY,CAAC,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC;IAClD,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,GAAG,QAAQ,CAAgB,IAAI,CAAC,CAAC;IAE1D,MAAM,IAAI,GAAG,WAAW,CACtB,KAAK,EAAE,gBAAwB,EAAE,MAAc,EAAE,EAAE;QACjD,IAAI,CAAC,eAAe,IAAI,CAAC,YAAY,EAAE,CAAC;YACtC,MAAM,IAAI,KAAK,CAAC,2BAA2B,CAAC,CAAC;QAC/C,CAAC;QAED,IAAI,CAAC,WAAW,EAAE,CAAC;YACjB,MAAM,IAAI,KAAK,CAAC,4BAA4B,CAAC,CAAC;QAChD,CAAC;QAED,+CAA+C;QAC/C,IAAI,YAAY,CAAC,IAAI,KAAK,QAAQ,EAAE,CAAC;YACnC,MAAM,IAAI,KAAK,CAAC,mEAAmE,CAAC,CAAC;QACvF,CAAC;QAED,YAAY,CAAC,IAAI,CAAC,CAAC;QACnB,IAAI,CAAC;YACH,MAAM,QA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;GAIG"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Validates an EVM address
|
|
3
|
+
*/
|
|
4
|
+
export declare function validateEvmAddress(address: string): boolean;
|
|
5
|
+
/**
|
|
6
|
+
* Validates a Solana address
|
|
7
|
+
*/
|
|
8
|
+
export declare function validateSolanaAddress(address: string): boolean;
|
|
9
|
+
/**
|
|
10
|
+
* Validates an address based on chain type
|
|
11
|
+
*/
|
|
12
|
+
export declare function validateAddress(address: string, chainType: 'evm' | 'solana'): boolean;
|
|
13
|
+
/**
|
|
14
|
+
* Validates address and checks if it's not the sender's address
|
|
15
|
+
*/
|
|
16
|
+
export declare function validateRecipientAddress(address: string, senderAddress: string | null | undefined, chainType: 'evm' | 'solana'): {
|
|
17
|
+
isValid: boolean;
|
|
18
|
+
error: string;
|
|
19
|
+
};
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Address validation utilities
|
|
3
|
+
*/
|
|
4
|
+
import { isAddress as isEvmAddress } from 'viem';
|
|
5
|
+
/**
|
|
6
|
+
* Validates an EVM address
|
|
7
|
+
*/
|
|
8
|
+
export function validateEvmAddress(address) {
|
|
9
|
+
if (!address)
|
|
10
|
+
return false;
|
|
11
|
+
try {
|
|
12
|
+
return isEvmAddress(address);
|
|
13
|
+
}
|
|
14
|
+
catch {
|
|
15
|
+
return false;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Validates a Solana address
|
|
20
|
+
*/
|
|
21
|
+
export function validateSolanaAddress(address) {
|
|
22
|
+
if (!address)
|
|
23
|
+
return false;
|
|
24
|
+
// Solana addresses are base58 encoded, typically 32-44 characters
|
|
25
|
+
// Basic validation: check length and base58 pattern
|
|
26
|
+
const base58Regex = /^[1-9A-HJ-NP-Za-km-z]{32,44}$/;
|
|
27
|
+
return base58Regex.test(address);
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Validates an address based on chain type
|
|
31
|
+
*/
|
|
32
|
+
export function validateAddress(address, chainType) {
|
|
33
|
+
if (!address || address.trim() === '') {
|
|
34
|
+
return false;
|
|
35
|
+
}
|
|
36
|
+
if (chainType === 'solana') {
|
|
37
|
+
return validateSolanaAddress(address);
|
|
38
|
+
}
|
|
39
|
+
else {
|
|
40
|
+
return validateEvmAddress(address);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Validates address and checks if it's not the sender's address
|
|
45
|
+
*/
|
|
46
|
+
export function validateRecipientAddress(address, senderAddress, chainType) {
|
|
47
|
+
if (!address || address.trim() === '') {
|
|
48
|
+
return { isValid: false, error: 'Recipient address is required' };
|
|
49
|
+
}
|
|
50
|
+
if (!validateAddress(address, chainType)) {
|
|
51
|
+
return {
|
|
52
|
+
isValid: false,
|
|
53
|
+
error: chainType === 'solana' ? 'Invalid Solana address' : 'Invalid EVM address',
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
// Check if sending to self
|
|
57
|
+
if (senderAddress && address.toLowerCase() === senderAddress.toLowerCase()) {
|
|
58
|
+
return { isValid: false, error: 'Cannot send to your own address' };
|
|
59
|
+
}
|
|
60
|
+
return { isValid: true, error: '' };
|
|
61
|
+
}
|
|
62
|
+
//# sourceMappingURL=addressUtils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"addressUtils.js","sourceRoot":"","sources":["../../../../../src/components/WalletModal/utils/addressUtils.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,EAAE,SAAS,IAAI,YAAY,EAAE,MAAM,MAAM,CAAC;AAEjD;;GAEG;AACH,MAAM,UAAU,kBAAkB,CAAC,OAAe;IAChD,IAAI,CAAC,OAAO;QAAE,OAAO,KAAK,CAAC;IAC3B,IAAI,CAAC;QACH,OAAO,YAAY,CAAC,OAAO,CAAC,CAAC;IAC/B,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,KAAK,CAAC;IACf,CAAC;AACH,CAAC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IAED,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,EAAE,EAAE,CAAC;AACtC,CAAC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Formatting utilities
|
|
3
|
+
*/
|
|
4
|
+
/**
|
|
5
|
+
* Formats an address to show first 6 and last 4 characters
|
|
6
|
+
*/
|
|
7
|
+
export declare function formatAddress(addr: string | null | undefined): string;
|
|
8
|
+
/**
|
|
9
|
+
* Formats a balance with proper decimals and symbol
|
|
10
|
+
* Removes trailing zeros and unnecessary decimals
|
|
11
|
+
*/
|
|
12
|
+
export declare function formatBalance(balance: bigint | null | undefined, decimals: number, symbol: string): string;
|
|
13
|
+
/**
|
|
14
|
+
* Formats a balance value (number) with proper decimals
|
|
15
|
+
*/
|
|
16
|
+
export declare function formatBalanceValue(balance: bigint | null | undefined, decimals: number): string;
|
|
17
|
+
/**
|
|
18
|
+
* Converts amount string to smallest unit (wei, lamports, etc.)
|
|
19
|
+
*/
|
|
20
|
+
export declare function amountToSmallestUnit(amount: string, decimals: number): bigint;
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Formatting utilities
|
|
3
|
+
*/
|
|
4
|
+
/**
|
|
5
|
+
* Formats an address to show first 6 and last 4 characters
|
|
6
|
+
*/
|
|
7
|
+
export function formatAddress(addr) {
|
|
8
|
+
if (!addr)
|
|
9
|
+
return '';
|
|
10
|
+
if (addr.length <= 10)
|
|
11
|
+
return addr;
|
|
12
|
+
return `${addr.slice(0, 6)}...${addr.slice(-4)}`;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Formats a balance with proper decimals and symbol
|
|
16
|
+
* Removes trailing zeros and unnecessary decimals
|
|
17
|
+
*/
|
|
18
|
+
export function formatBalance(balance, decimals, symbol) {
|
|
19
|
+
if (!balance || balance === 0n)
|
|
20
|
+
return `0 ${symbol}`;
|
|
21
|
+
const balanceValue = Number(balance) / Math.pow(10, decimals);
|
|
22
|
+
// Remove trailing zeros and unnecessary decimals
|
|
23
|
+
// Use toFixed with max decimals, then remove trailing zeros
|
|
24
|
+
const formatted = balanceValue.toFixed(decimals);
|
|
25
|
+
// Remove trailing zeros and decimal point if not needed
|
|
26
|
+
const trimmed = formatted.replace(/\.?0+$/, '');
|
|
27
|
+
return `${trimmed} ${symbol}`;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Formats a balance value (number) with proper decimals
|
|
31
|
+
*/
|
|
32
|
+
export function formatBalanceValue(balance, decimals) {
|
|
33
|
+
if (!balance || balance === 0n)
|
|
34
|
+
return '0';
|
|
35
|
+
return (Number(balance) / Math.pow(10, decimals)).toFixed(6);
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Converts amount string to smallest unit (wei, lamports, etc.)
|
|
39
|
+
*/
|
|
40
|
+
export function amountToSmallestUnit(amount, decimals) {
|
|
41
|
+
const numAmount = parseFloat(amount);
|
|
42
|
+
if (isNaN(numAmount) || numAmount <= 0) {
|
|
43
|
+
return 0n;
|
|
44
|
+
}
|
|
45
|
+
return BigInt(Math.floor(numAmount * Math.pow(10, decimals)));
|
|
46
|
+
}
|
|
47
|
+
//# sourceMappingURL=formatUtils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"formatUtils.js","sourceRoot":"","sources":["../../../../../src/components/WalletModal/utils/formatUtils.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH;;GAEG;AACH,MAAM,UAAU,aAAa,CAAC,IAA+B;IAC3D,IAAI,CAAC,IAAI;QAAE,OAAO,EAAE,CAAC;IACrB,IAAI,IAAI,CAAC,MAAM,IAAI,EAAE;QAAE,OAAO,IAAI,CAAC;IACnC,OAAO,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,MAAM,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;AACnD,CAAC;AAED;;;GAGG;AACH,MAAM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src/components/WalletModal/utils/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,cAAc,gBAAgB,CAAC;AAC/B,cAAc,eAAe,CAAC"}
|
package/dist/src/index.d.ts
CHANGED
|
@@ -10,5 +10,6 @@ export type { ConnectButtonProps, ConnectButtonVariant, ConnectButtonSize } from
|
|
|
10
10
|
export { WalletModal } from './WalletModal';
|
|
11
11
|
export type { WalletModalProps } from './WalletModal';
|
|
12
12
|
export { OnboardingUIComponent as OnboardingUI } from './OnboardingUI';
|
|
13
|
-
export type { AbstraxnProviderConfig, AbstraxnUIConfig, AbstraxnContextValue, } from './types';
|
|
13
|
+
export type { AbstraxnProviderConfig, AbstraxnUIConfig, AbstraxnContextValue, ChainConfig, } from './types';
|
|
14
14
|
export type { OnboardingUIComponentProps, OnboardingUIComponentRef } from './OnboardingUI';
|
|
15
|
+
export { ALL_CHAINS, EVM_CHAINS, SOLANA_CHAINS, getChainById, getChainsByType, getDefaultChains, toCoreChain, type ChainData, } from './chains';
|
package/dist/src/index.js
CHANGED
|
@@ -8,4 +8,5 @@ export { useIsConnected, useAddress, useUser, useChainId, useIsInitialized, useL
|
|
|
8
8
|
export { ConnectButton } from './ConnectButton';
|
|
9
9
|
export { WalletModal } from './WalletModal';
|
|
10
10
|
export { OnboardingUIComponent as OnboardingUI } from './OnboardingUI';
|
|
11
|
+
export { ALL_CHAINS, EVM_CHAINS, SOLANA_CHAINS, getChainById, getChainsByType, getDefaultChains, toCoreChain, } from './chains';
|
|
11
12
|
//# sourceMappingURL=index.js.map
|
package/dist/src/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.tsx"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AACzE,OAAO,EACL,cAAc,EACd,UAAU,EACV,OAAO,EACP,UAAU,EACV,gBAAgB,EAChB,UAAU,EACV,QAAQ,EACR,SAAS,EACT,qBAAqB,EACrB,kBAAkB,EAClB,yBAAyB,EACzB,eAAe,EACf,SAAS,EACT,iBAAiB,EACjB,wBAAwB,EACxB,sBAAsB,EACtB,qBAAqB,GACtB,MAAM,SAAS,CAAC;AACjB,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAEhD,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAE5C,OAAO,EAAE,qBAAqB,IAAI,YAAY,EAAE,MAAM,gBAAgB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.tsx"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AACzE,OAAO,EACL,cAAc,EACd,UAAU,EACV,OAAO,EACP,UAAU,EACV,gBAAgB,EAChB,UAAU,EACV,QAAQ,EACR,SAAS,EACT,qBAAqB,EACrB,kBAAkB,EAClB,yBAAyB,EACzB,eAAe,EACf,SAAS,EACT,iBAAiB,EACjB,wBAAwB,EACxB,sBAAsB,EACtB,qBAAqB,GACtB,MAAM,SAAS,CAAC;AACjB,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAEhD,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAE5C,OAAO,EAAE,qBAAqB,IAAI,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAUvE,OAAO,EACL,UAAU,EACV,UAAU,EACV,aAAa,EACb,YAAY,EACZ,eAAe,EACf,gBAAgB,EAChB,WAAW,GAEZ,MAAM,UAAU,CAAC"}
|
package/dist/src/types.d.ts
CHANGED
|
@@ -106,6 +106,27 @@ export interface ExternalWalletConfig {
|
|
|
106
106
|
*/
|
|
107
107
|
connectors?: ('injected' | 'metaMask' | 'walletConnect')[];
|
|
108
108
|
}
|
|
109
|
+
/**
|
|
110
|
+
* Chain Configuration
|
|
111
|
+
*/
|
|
112
|
+
export interface ChainConfig {
|
|
113
|
+
/**
|
|
114
|
+
* Supported EVM chain IDs to show in chain selector
|
|
115
|
+
* If not provided, shows default chains (Ethereum, Polygon, Base)
|
|
116
|
+
* Use chain names from chains.ts: 'ethereum', 'sepolia', 'polygon', 'polygon-amoy', 'base', 'base-sepolia'
|
|
117
|
+
*/
|
|
118
|
+
supportedEvmChains?: string[];
|
|
119
|
+
/**
|
|
120
|
+
* Enable Solana chains in selector
|
|
121
|
+
* @default false
|
|
122
|
+
*/
|
|
123
|
+
enableSolana?: boolean;
|
|
124
|
+
/**
|
|
125
|
+
* Default chain ID to use
|
|
126
|
+
* If not provided, uses the first supported chain
|
|
127
|
+
*/
|
|
128
|
+
defaultChainId?: number;
|
|
129
|
+
}
|
|
109
130
|
/**
|
|
110
131
|
* Complete configuration for AbstraxnProvider
|
|
111
132
|
*/
|
|
@@ -128,6 +149,10 @@ export interface AbstraxnProviderConfig extends AbstraxnWalletConfig {
|
|
|
128
149
|
* External wallet configuration
|
|
129
150
|
*/
|
|
130
151
|
externalWallets?: ExternalWalletConfig;
|
|
152
|
+
/**
|
|
153
|
+
* Chain configuration
|
|
154
|
+
*/
|
|
155
|
+
chains?: ChainConfig;
|
|
131
156
|
}
|
|
132
157
|
/**
|
|
133
158
|
* Context value type
|
|
@@ -178,4 +203,8 @@ export interface AbstraxnContextValue {
|
|
|
178
203
|
}>;
|
|
179
204
|
switchExternalWalletChain?: (chainId: number) => Promise<void>;
|
|
180
205
|
uiConfig?: AbstraxnUIConfig;
|
|
206
|
+
switchChainEnhanced?: (chainId: number) => Promise<void>;
|
|
207
|
+
currentChain?: import('./chains').ChainData | null;
|
|
208
|
+
availableChains?: import('./chains').ChainData[];
|
|
209
|
+
walletBalance?: bigint | null;
|
|
181
210
|
}
|
package/dist/src/wagmiConfig.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Wagmi configuration for external wallet support
|
|
3
3
|
*/
|
|
4
|
-
import { createConfig, http } from '@wagmi/core';
|
|
4
|
+
import { createConfig, createStorage, http } from '@wagmi/core';
|
|
5
5
|
import { injected, walletConnect } from 'wagmi/connectors';
|
|
6
6
|
import { polygonAmoy } from 'viem/chains';
|
|
7
7
|
import { SUPPORTED_CHAINS } from 'signer-test-sdk-core';
|
|
@@ -74,7 +74,11 @@ export function createWagmiConfig(chains, walletConnectProjectId, enabledConnect
|
|
|
74
74
|
acc[chain.id] = http();
|
|
75
75
|
return acc;
|
|
76
76
|
}, {}),
|
|
77
|
-
//
|
|
77
|
+
// Configure storage to use localStorage for persistence
|
|
78
|
+
// This enables automatic connection restoration on page reload
|
|
79
|
+
storage: typeof window !== 'undefined'
|
|
80
|
+
? createStorage({ storage: window.localStorage })
|
|
81
|
+
: undefined,
|
|
78
82
|
ssr: false,
|
|
79
83
|
});
|
|
80
84
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"wagmiConfig.js","sourceRoot":"","sources":["../../src/wagmiConfig.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,EAAE,YAAY,EAAE,IAAI,EAAe,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"wagmiConfig.js","sourceRoot":"","sources":["../../src/wagmiConfig.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,IAAI,EAAe,MAAM,aAAa,CAAC;AAC7E,OAAO,EAAE,QAAQ,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAE3D,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC1C,OAAO,EAAE,gBAAgB,EAA2B,MAAM,sBAAsB,CAAC;AAEjF;;;GAGG;AACH,SAAS,kBAAkB,CAAC,KAAgB;IAC1C,0DAA0D;IAC1D,IAAI,KAAK,CAAC,EAAE,KAAK,KAAK,EAAE,CAAC;QACvB,OAAO,WAAW,CAAC;IACrB,CAAC;IAED,OAAO;QACL,EAAE,EAAE,K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