@varity-labs/ui-kit 2.0.0-beta.8 → 2.0.0-beta.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/dist/components/Dashboard/DashboardHeader.js +4 -4
- package/dist/components/Dashboard/DashboardHeader.js.map +1 -1
- package/dist/components/Dashboard/DashboardLayout.d.ts +3 -3
- package/dist/components/Dashboard/DashboardLayout.d.ts.map +1 -1
- package/dist/components/Dashboard/DashboardLayout.js +1 -1
- package/dist/components/InAppWallet/EmailLoginButton.d.ts +27 -0
- package/dist/components/InAppWallet/EmailLoginButton.d.ts.map +1 -0
- package/dist/components/InAppWallet/EmailLoginButton.js +84 -0
- package/dist/components/InAppWallet/EmailLoginButton.js.map +1 -0
- package/dist/components/InAppWallet/InAppWalletProvider.d.ts +54 -0
- package/dist/components/InAppWallet/InAppWalletProvider.d.ts.map +1 -0
- package/dist/components/InAppWallet/InAppWalletProvider.js +225 -0
- package/dist/components/InAppWallet/InAppWalletProvider.js.map +1 -0
- package/dist/components/InAppWallet/OnboardingFlow.d.ts +25 -0
- package/dist/components/InAppWallet/OnboardingFlow.d.ts.map +1 -0
- package/dist/components/InAppWallet/OnboardingFlow.js +159 -0
- package/dist/components/InAppWallet/OnboardingFlow.js.map +1 -0
- package/dist/components/InAppWallet/SocialLoginButtons.d.ts +28 -0
- package/dist/components/InAppWallet/SocialLoginButtons.d.ts.map +1 -0
- package/dist/components/InAppWallet/SocialLoginButtons.js +128 -0
- package/dist/components/InAppWallet/SocialLoginButtons.js.map +1 -0
- package/dist/components/InAppWallet/index.d.ts +15 -0
- package/dist/components/InAppWallet/index.d.ts.map +1 -0
- package/dist/components/InAppWallet/index.js +14 -0
- package/dist/components/InAppWallet/index.js.map +1 -0
- package/dist/components/PaymentWidget/PaymentWidget.d.ts +19 -7
- package/dist/components/PaymentWidget/PaymentWidget.d.ts.map +1 -1
- package/dist/components/PaymentWidget/PaymentWidget.js +176 -10
- package/dist/components/PaymentWidget/PaymentWidget.js.map +1 -1
- package/dist/components/PaymentWidget/useSeamlessPayment.d.ts +34 -8
- package/dist/components/PaymentWidget/useSeamlessPayment.d.ts.map +1 -1
- package/dist/components/PaymentWidget/useSeamlessPayment.js +158 -12
- package/dist/components/PaymentWidget/useSeamlessPayment.js.map +1 -1
- package/dist/components/PaymentWidget/useVarityPayment.d.ts +6 -5
- package/dist/components/PaymentWidget/useVarityPayment.d.ts.map +1 -1
- package/dist/components/PaymentWidget/useVarityPayment.js +147 -11
- package/dist/components/PaymentWidget/useVarityPayment.js.map +1 -1
- package/dist/components/Payments/CheckoutModal.d.ts +19 -0
- package/dist/components/Payments/CheckoutModal.d.ts.map +1 -0
- package/dist/components/Payments/CheckoutModal.js +194 -0
- package/dist/components/Payments/CheckoutModal.js.map +1 -0
- package/dist/components/Payments/SubscriptionWidget.d.ts +17 -0
- package/dist/components/Payments/SubscriptionWidget.d.ts.map +1 -0
- package/dist/components/Payments/SubscriptionWidget.js +89 -0
- package/dist/components/Payments/SubscriptionWidget.js.map +1 -0
- package/dist/components/Payments/constants.d.ts +59 -0
- package/dist/components/Payments/constants.d.ts.map +1 -0
- package/dist/components/Payments/constants.js +145 -0
- package/dist/components/Payments/constants.js.map +1 -0
- package/dist/components/Payments/index.d.ts +10 -0
- package/dist/components/Payments/index.d.ts.map +1 -0
- package/dist/components/Payments/index.js +12 -0
- package/dist/components/Payments/index.js.map +1 -0
- package/dist/components/Payments/types.d.ts +119 -0
- package/dist/components/Payments/types.d.ts.map +1 -0
- package/dist/components/Payments/types.js +27 -0
- package/dist/components/Payments/types.js.map +1 -0
- package/dist/components/Payments/usePayments.d.ts +33 -0
- package/dist/components/Payments/usePayments.d.ts.map +1 -0
- package/dist/components/Payments/usePayments.js +249 -0
- package/dist/components/Payments/usePayments.js.map +1 -0
- package/dist/components/SIWE/AuthStatus.d.ts +15 -0
- package/dist/components/SIWE/AuthStatus.d.ts.map +1 -0
- package/dist/components/SIWE/AuthStatus.js +47 -0
- package/dist/components/SIWE/AuthStatus.js.map +1 -0
- package/dist/components/SIWE/ProtectedRoute.d.ts +17 -0
- package/dist/components/SIWE/ProtectedRoute.d.ts.map +1 -0
- package/dist/components/SIWE/ProtectedRoute.js +52 -0
- package/dist/components/SIWE/ProtectedRoute.js.map +1 -0
- package/dist/components/SIWE/SIWEButton.d.ts +22 -0
- package/dist/components/SIWE/SIWEButton.d.ts.map +1 -0
- package/dist/components/SIWE/SIWEButton.js +106 -0
- package/dist/components/SIWE/SIWEButton.js.map +1 -0
- package/dist/components/SIWE/SIWEModal.d.ts +19 -0
- package/dist/components/SIWE/SIWEModal.d.ts.map +1 -0
- package/dist/components/SIWE/SIWEModal.js +75 -0
- package/dist/components/SIWE/SIWEModal.js.map +1 -0
- package/dist/components/SIWE/SIWEProvider.d.ts +38 -0
- package/dist/components/SIWE/SIWEProvider.d.ts.map +1 -0
- package/dist/components/SIWE/SIWEProvider.js +227 -0
- package/dist/components/SIWE/SIWEProvider.js.map +1 -0
- package/dist/components/SIWE/index.d.ts +15 -0
- package/dist/components/SIWE/index.d.ts.map +1 -0
- package/dist/components/SIWE/index.js +10 -0
- package/dist/components/SIWE/index.js.map +1 -0
- package/dist/hooks/web3/index.d.ts +5 -0
- package/dist/hooks/web3/index.d.ts.map +1 -0
- package/dist/hooks/web3/index.js +6 -0
- package/dist/hooks/web3/index.js.map +1 -0
- package/dist/hooks/web3/useAddressValidation.d.ts +37 -0
- package/dist/hooks/web3/useAddressValidation.d.ts.map +1 -0
- package/dist/hooks/web3/useAddressValidation.js +59 -0
- package/dist/hooks/web3/useAddressValidation.js.map +1 -0
- package/dist/hooks/web3/useBlockExplorer.d.ts +37 -0
- package/dist/hooks/web3/useBlockExplorer.d.ts.map +1 -0
- package/dist/hooks/web3/useBlockExplorer.js +59 -0
- package/dist/hooks/web3/useBlockExplorer.js.map +1 -0
- package/dist/hooks/web3/useUSDCFormat.d.ts +34 -0
- package/dist/hooks/web3/useUSDCFormat.d.ts.map +1 -0
- package/dist/hooks/web3/useUSDCFormat.js +43 -0
- package/dist/hooks/web3/useUSDCFormat.js.map +1 -0
- package/dist/hooks/web3/useVarityWallet.d.ts +48 -0
- package/dist/hooks/web3/useVarityWallet.d.ts.map +1 -0
- package/dist/hooks/web3/useVarityWallet.js +70 -0
- package/dist/hooks/web3/useVarityWallet.js.map +1 -0
- package/dist/providers/ChainContext.d.ts +65 -0
- package/dist/providers/ChainContext.d.ts.map +1 -0
- package/dist/providers/ChainContext.js +92 -0
- package/dist/providers/ChainContext.js.map +1 -0
- package/dist/providers/PrivyStack.d.ts +17 -50
- package/dist/providers/PrivyStack.d.ts.map +1 -1
- package/dist/providers/PrivyStack.js +15 -43
- package/dist/providers/PrivyStack.js.map +1 -1
- package/dist/providers/VarityDashboardProvider.d.ts +2 -2
- package/dist/providers/VarityDashboardProvider.d.ts.map +1 -1
- package/dist/providers/VarityDashboardProvider.js +26 -3
- package/dist/providers/VarityDashboardProvider.js.map +1 -1
- package/dist/providers/VarityProvider.d.ts +32 -0
- package/dist/providers/VarityProvider.d.ts.map +1 -0
- package/dist/providers/VarityProvider.js +56 -0
- package/dist/providers/VarityProvider.js.map +1 -0
- package/dist/providers/WalletContext.d.ts +68 -0
- package/dist/providers/WalletContext.d.ts.map +1 -0
- package/dist/providers/WalletContext.js +98 -0
- package/dist/providers/WalletContext.js.map +1 -0
- package/dist/providers/WalletSyncProvider.d.ts +15 -18
- package/dist/providers/WalletSyncProvider.d.ts.map +1 -1
- package/dist/providers/WalletSyncProvider.js +12 -15
- package/dist/providers/WalletSyncProvider.js.map +1 -1
- package/dist/providers/index.d.ts +48 -0
- package/dist/providers/index.d.ts.map +1 -0
- package/dist/providers/index.js +53 -0
- package/dist/providers/index.js.map +1 -0
- package/dist/wallets/SimpleSmartWallet.d.ts +68 -0
- package/dist/wallets/SimpleSmartWallet.d.ts.map +1 -0
- package/dist/wallets/SimpleSmartWallet.js +74 -0
- package/dist/wallets/SimpleSmartWallet.js.map +1 -0
- package/dist/wallets/SmartWalletProvider.d.ts +217 -0
- package/dist/wallets/SmartWalletProvider.d.ts.map +1 -0
- package/dist/wallets/SmartWalletProvider.js +366 -0
- package/dist/wallets/SmartWalletProvider.js.map +1 -0
- package/dist/wallets/config.d.ts +222 -0
- package/dist/wallets/config.d.ts.map +1 -0
- package/dist/wallets/config.js +206 -0
- package/dist/wallets/config.js.map +1 -0
- package/dist/wallets/index.d.ts +9 -0
- package/dist/wallets/index.d.ts.map +1 -0
- package/dist/wallets/index.js +9 -0
- package/dist/wallets/index.js.map +1 -0
- package/dist/web3/AddressDisplay/AddressDisplay.d.ts +33 -0
- package/dist/web3/AddressDisplay/AddressDisplay.d.ts.map +1 -0
- package/dist/web3/AddressDisplay/AddressDisplay.js +42 -0
- package/dist/web3/AddressDisplay/AddressDisplay.js.map +1 -0
- package/dist/web3/AddressInput/AddressInput.d.ts +36 -0
- package/dist/web3/AddressInput/AddressInput.d.ts.map +1 -0
- package/dist/web3/AddressInput/AddressInput.js +54 -0
- package/dist/web3/AddressInput/AddressInput.js.map +1 -0
- package/dist/web3/AmountInput/AmountInput.d.ts +41 -0
- package/dist/web3/AmountInput/AmountInput.d.ts.map +1 -0
- package/dist/web3/AmountInput/AmountInput.js +74 -0
- package/dist/web3/AmountInput/AmountInput.js.map +1 -0
- package/dist/web3/BalanceDisplay/BalanceDisplay.d.ts +30 -0
- package/dist/web3/BalanceDisplay/BalanceDisplay.d.ts.map +1 -0
- package/dist/web3/BalanceDisplay/BalanceDisplay.js +35 -0
- package/dist/web3/BalanceDisplay/BalanceDisplay.js.map +1 -0
- package/dist/web3/BlockExplorerLink/BlockExplorerLink.d.ts +41 -0
- package/dist/web3/BlockExplorerLink/BlockExplorerLink.d.ts.map +1 -0
- package/dist/web3/BlockExplorerLink/BlockExplorerLink.js +46 -0
- package/dist/web3/BlockExplorerLink/BlockExplorerLink.js.map +1 -0
- package/dist/web3/ConnectWallet/ConnectWallet.d.ts +35 -0
- package/dist/web3/ConnectWallet/ConnectWallet.d.ts.map +1 -0
- package/dist/web3/ConnectWallet/ConnectWallet.js +58 -0
- package/dist/web3/ConnectWallet/ConnectWallet.js.map +1 -0
- package/dist/web3/DisconnectButton/DisconnectButton.d.ts +30 -0
- package/dist/web3/DisconnectButton/DisconnectButton.d.ts.map +1 -0
- package/dist/web3/DisconnectButton/DisconnectButton.js +48 -0
- package/dist/web3/DisconnectButton/DisconnectButton.js.map +1 -0
- package/dist/web3/WalletBalance/WalletBalance.d.ts +27 -0
- package/dist/web3/WalletBalance/WalletBalance.d.ts.map +1 -0
- package/dist/web3/WalletBalance/WalletBalance.js +49 -0
- package/dist/web3/WalletBalance/WalletBalance.js.map +1 -0
- package/dist/web3/WalletDropdown/WalletDropdown.d.ts +29 -0
- package/dist/web3/WalletDropdown/WalletDropdown.d.ts.map +1 -0
- package/dist/web3/WalletDropdown/WalletDropdown.js +93 -0
- package/dist/web3/WalletDropdown/WalletDropdown.js.map +1 -0
- package/dist/web3/WalletInfo/WalletInfo.d.ts +31 -0
- package/dist/web3/WalletInfo/WalletInfo.d.ts.map +1 -0
- package/dist/web3/WalletInfo/WalletInfo.js +41 -0
- package/dist/web3/WalletInfo/WalletInfo.js.map +1 -0
- package/dist/web3/index.d.ts +11 -0
- package/dist/web3/index.d.ts.map +1 -0
- package/dist/web3/index.js +14 -0
- package/dist/web3/index.js.map +1 -0
- package/package.json +4 -3
|
@@ -0,0 +1,227 @@
|
|
|
1
|
+
import React, { createContext, useContext, useState, useEffect, useCallback } from 'react';
|
|
2
|
+
import axios from 'axios';
|
|
3
|
+
import { useActiveAccount, useActiveWallet } from 'thirdweb/react';
|
|
4
|
+
const AuthContext = createContext(undefined);
|
|
5
|
+
/**
|
|
6
|
+
* SIWE Provider Component
|
|
7
|
+
* Manages authentication state and provides login/logout functionality
|
|
8
|
+
*/
|
|
9
|
+
export const SIWEProvider = ({ children, apiUrl, chainId = 33529, // Varity L3 Chain ID
|
|
10
|
+
onLoginSuccess, onLoginError, onLogoutSuccess, }) => {
|
|
11
|
+
const [authState, setAuthState] = useState({
|
|
12
|
+
isAuthenticated: false,
|
|
13
|
+
isLoading: false,
|
|
14
|
+
user: null,
|
|
15
|
+
accessToken: null,
|
|
16
|
+
refreshToken: null,
|
|
17
|
+
error: null,
|
|
18
|
+
});
|
|
19
|
+
const account = useActiveAccount();
|
|
20
|
+
const wallet = useActiveWallet();
|
|
21
|
+
const apiClient = axios.create({ baseURL: apiUrl });
|
|
22
|
+
const clearStoredAuth = useCallback(() => {
|
|
23
|
+
localStorage.removeItem('varity_access_token');
|
|
24
|
+
localStorage.removeItem('varity_refresh_token');
|
|
25
|
+
localStorage.removeItem('varity_user');
|
|
26
|
+
}, []);
|
|
27
|
+
// Load tokens from localStorage on mount
|
|
28
|
+
useEffect(() => {
|
|
29
|
+
const loadStoredAuth = () => {
|
|
30
|
+
try {
|
|
31
|
+
const accessToken = localStorage.getItem('varity_access_token');
|
|
32
|
+
const refreshToken = localStorage.getItem('varity_refresh_token');
|
|
33
|
+
const userStr = localStorage.getItem('varity_user');
|
|
34
|
+
if (accessToken && refreshToken && userStr) {
|
|
35
|
+
const user = JSON.parse(userStr);
|
|
36
|
+
setAuthState({
|
|
37
|
+
isAuthenticated: true,
|
|
38
|
+
isLoading: false,
|
|
39
|
+
user,
|
|
40
|
+
accessToken,
|
|
41
|
+
refreshToken,
|
|
42
|
+
error: null,
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
catch (error) {
|
|
47
|
+
console.error('Failed to load stored auth:', error);
|
|
48
|
+
clearStoredAuth();
|
|
49
|
+
}
|
|
50
|
+
};
|
|
51
|
+
loadStoredAuth();
|
|
52
|
+
}, [clearStoredAuth]);
|
|
53
|
+
// Setup axios interceptor for adding auth token
|
|
54
|
+
useEffect(() => {
|
|
55
|
+
if (authState.accessToken) {
|
|
56
|
+
const interceptorId = apiClient.interceptors.request.use((config) => {
|
|
57
|
+
config.headers.Authorization = `Bearer ${authState.accessToken}`;
|
|
58
|
+
return config;
|
|
59
|
+
}, (error) => Promise.reject(error));
|
|
60
|
+
return () => {
|
|
61
|
+
apiClient.interceptors.request.eject(interceptorId);
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
65
|
+
}, [authState.accessToken]);
|
|
66
|
+
const saveAuthToStorage = useCallback((accessToken, refreshToken, user) => {
|
|
67
|
+
localStorage.setItem('varity_access_token', accessToken);
|
|
68
|
+
localStorage.setItem('varity_refresh_token', refreshToken);
|
|
69
|
+
localStorage.setItem('varity_user', JSON.stringify(user));
|
|
70
|
+
}, []);
|
|
71
|
+
/**
|
|
72
|
+
* Login with SIWE
|
|
73
|
+
* 1. Get nonce from backend
|
|
74
|
+
* 2. Sign SIWE message with wallet
|
|
75
|
+
* 3. Submit signature to backend
|
|
76
|
+
* 4. Receive JWT tokens
|
|
77
|
+
*/
|
|
78
|
+
const login = useCallback(async () => {
|
|
79
|
+
if (!account || !wallet) {
|
|
80
|
+
const error = new Error('Wallet not connected');
|
|
81
|
+
setAuthState(prev => ({ ...prev, error: error.message }));
|
|
82
|
+
onLoginError?.(error);
|
|
83
|
+
return;
|
|
84
|
+
}
|
|
85
|
+
try {
|
|
86
|
+
setAuthState(prev => ({ ...prev, isLoading: true, error: null }));
|
|
87
|
+
// Step 1: Get nonce from backend
|
|
88
|
+
const nonceResponse = await apiClient.post('/api/v1/auth/nonce', {
|
|
89
|
+
address: account.address,
|
|
90
|
+
chainId,
|
|
91
|
+
});
|
|
92
|
+
const siweMessage = nonceResponse.data.data.message;
|
|
93
|
+
// Step 2: Create EIP-4361 formatted message
|
|
94
|
+
const messageToSign = formatSiweMessage(siweMessage);
|
|
95
|
+
// Step 3: Sign message with wallet (v5 API uses account.signMessage)
|
|
96
|
+
const signature = await account.signMessage({
|
|
97
|
+
message: messageToSign,
|
|
98
|
+
});
|
|
99
|
+
// Step 4: Submit signature to backend for verification
|
|
100
|
+
const loginResponse = await apiClient.post('/api/v1/auth/login', {
|
|
101
|
+
message: siweMessage,
|
|
102
|
+
signature,
|
|
103
|
+
});
|
|
104
|
+
const { accessToken, refreshToken, user } = loginResponse.data.data;
|
|
105
|
+
// Save tokens to localStorage
|
|
106
|
+
saveAuthToStorage(accessToken, refreshToken, user);
|
|
107
|
+
// Update state
|
|
108
|
+
setAuthState({
|
|
109
|
+
isAuthenticated: true,
|
|
110
|
+
isLoading: false,
|
|
111
|
+
user,
|
|
112
|
+
accessToken,
|
|
113
|
+
refreshToken,
|
|
114
|
+
error: null,
|
|
115
|
+
});
|
|
116
|
+
onLoginSuccess?.(user);
|
|
117
|
+
}
|
|
118
|
+
catch (error) {
|
|
119
|
+
const errorMessage = error.response?.data?.message || error.message || 'Authentication failed';
|
|
120
|
+
setAuthState({
|
|
121
|
+
isAuthenticated: false,
|
|
122
|
+
isLoading: false,
|
|
123
|
+
user: null,
|
|
124
|
+
accessToken: null,
|
|
125
|
+
refreshToken: null,
|
|
126
|
+
error: errorMessage,
|
|
127
|
+
});
|
|
128
|
+
onLoginError?.(new Error(errorMessage));
|
|
129
|
+
clearStoredAuth();
|
|
130
|
+
}
|
|
131
|
+
}, [account, wallet, chainId, apiClient, onLoginSuccess, onLoginError, saveAuthToStorage, clearStoredAuth]);
|
|
132
|
+
/**
|
|
133
|
+
* Logout
|
|
134
|
+
* Clears authentication state and localStorage
|
|
135
|
+
*/
|
|
136
|
+
const logout = useCallback(async () => {
|
|
137
|
+
try {
|
|
138
|
+
// Call backend logout endpoint
|
|
139
|
+
if (authState.accessToken) {
|
|
140
|
+
await apiClient.post('/api/v1/auth/logout', {}, {
|
|
141
|
+
headers: { Authorization: `Bearer ${authState.accessToken}` }
|
|
142
|
+
});
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
catch (error) {
|
|
146
|
+
console.error('Logout error:', error);
|
|
147
|
+
}
|
|
148
|
+
finally {
|
|
149
|
+
// Clear state regardless of backend response
|
|
150
|
+
setAuthState({
|
|
151
|
+
isAuthenticated: false,
|
|
152
|
+
isLoading: false,
|
|
153
|
+
user: null,
|
|
154
|
+
accessToken: null,
|
|
155
|
+
refreshToken: null,
|
|
156
|
+
error: null,
|
|
157
|
+
});
|
|
158
|
+
clearStoredAuth();
|
|
159
|
+
onLogoutSuccess?.();
|
|
160
|
+
}
|
|
161
|
+
}, [authState.accessToken, apiClient, clearStoredAuth, onLogoutSuccess]);
|
|
162
|
+
/**
|
|
163
|
+
* Refresh access token using refresh token
|
|
164
|
+
*/
|
|
165
|
+
const refreshAccessToken = useCallback(async () => {
|
|
166
|
+
if (!authState.refreshToken) {
|
|
167
|
+
return;
|
|
168
|
+
}
|
|
169
|
+
try {
|
|
170
|
+
const response = await apiClient.post('/api/v1/auth/refresh', {
|
|
171
|
+
refreshToken: authState.refreshToken,
|
|
172
|
+
});
|
|
173
|
+
const { accessToken } = response.data.data;
|
|
174
|
+
// Update access token
|
|
175
|
+
localStorage.setItem('varity_access_token', accessToken);
|
|
176
|
+
setAuthState(prev => ({ ...prev, accessToken }));
|
|
177
|
+
}
|
|
178
|
+
catch (error) {
|
|
179
|
+
console.error('Token refresh failed:', error);
|
|
180
|
+
// If refresh fails, logout
|
|
181
|
+
await logout();
|
|
182
|
+
}
|
|
183
|
+
}, [authState.refreshToken, apiClient, logout]);
|
|
184
|
+
// Auto-refresh token every 30 minutes
|
|
185
|
+
useEffect(() => {
|
|
186
|
+
if (authState.isAuthenticated && authState.refreshToken) {
|
|
187
|
+
const interval = setInterval(() => {
|
|
188
|
+
refreshAccessToken();
|
|
189
|
+
}, 30 * 60 * 1000); // 30 minutes
|
|
190
|
+
return () => clearInterval(interval);
|
|
191
|
+
}
|
|
192
|
+
}, [authState.isAuthenticated, authState.refreshToken, refreshAccessToken]);
|
|
193
|
+
const contextValue = {
|
|
194
|
+
...authState,
|
|
195
|
+
login,
|
|
196
|
+
logout,
|
|
197
|
+
refreshAccessToken,
|
|
198
|
+
};
|
|
199
|
+
return (React.createElement(AuthContext.Provider, { value: contextValue }, children));
|
|
200
|
+
};
|
|
201
|
+
/**
|
|
202
|
+
* Format SIWE message according to EIP-4361
|
|
203
|
+
*/
|
|
204
|
+
function formatSiweMessage(message) {
|
|
205
|
+
return `${message.domain} wants you to sign in with your Ethereum account:
|
|
206
|
+
${message.address}
|
|
207
|
+
|
|
208
|
+
${message.statement}
|
|
209
|
+
|
|
210
|
+
URI: ${message.uri}
|
|
211
|
+
Version: ${message.version}
|
|
212
|
+
Chain ID: ${message.chainId}
|
|
213
|
+
Nonce: ${message.nonce}
|
|
214
|
+
Issued At: ${message.issuedAt}${message.expirationTime ? `\nExpiration Time: ${message.expirationTime}` : ''}`;
|
|
215
|
+
}
|
|
216
|
+
/**
|
|
217
|
+
* Custom hook to use SIWE authentication context
|
|
218
|
+
*/
|
|
219
|
+
export const useSIWE = () => {
|
|
220
|
+
const context = useContext(AuthContext);
|
|
221
|
+
if (!context) {
|
|
222
|
+
throw new Error('useSIWE must be used within SIWEProvider');
|
|
223
|
+
}
|
|
224
|
+
return context;
|
|
225
|
+
};
|
|
226
|
+
export default SIWEProvider;
|
|
227
|
+
//# sourceMappingURL=SIWEProvider.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SIWEProvider.js","sourceRoot":"","sources":["../../../src/components/SIWE/SIWEProvider.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,aAAa,EAAE,UAAU,EAAE,QAAQ,EAAE,SAAS,EAAE,WAAW,EAAa,MAAM,OAAO,CAAC;AACtG,OAAO,KAAwB,MAAM,OAAO,CAAC;AAC7C,OAAO,EAAE,gBAAgB,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAiDnE,MAAM,WAAW,GAAG,aAAa,CAA+B,SAAS,CAAC,CAAC;AAE3E;;;GAGG;AACH,MAAM,CAAC,MAAM,YAAY,GAAgC,CAAC,EACxD,QAAQ,EACR,MAAM,EACN,OAAO,GAAG,KAAK,EAAE,qBAAqB;AACtC,cAAc,EACd,YAAY,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E (Sign-In with Ethereum) Components
|
|
3
|
+
* EIP-4361 compliant authentication components for Web3 applications
|
|
4
|
+
*/
|
|
5
|
+
export { SIWEProvider, useSIWE } from './SIWEProvider';
|
|
6
|
+
export { SIWEButton } from './SIWEButton';
|
|
7
|
+
export { SIWEModal } from './SIWEModal';
|
|
8
|
+
export { ProtectedRoute } from './ProtectedRoute';
|
|
9
|
+
export { AuthStatus } from './AuthStatus';
|
|
10
|
+
export type { default as SIWEProviderProps } from './SIWEProvider';
|
|
11
|
+
export type { default as SIWEButtonProps } from './SIWEButton';
|
|
12
|
+
export type { default as SIWEModalProps } from './SIWEModal';
|
|
13
|
+
export type { default as ProtectedRouteProps } from './ProtectedRoute';
|
|
14
|
+
export type { default as AuthStatusProps } from './AuthStatus';
|
|
15
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/SIWE/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,YAAY,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AACvD,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAG1C,YAAY,EAAE,OAAO,IAAI,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AACnE,YAAY,EAAE,OAAO,IAAI,eAAe,EAAE,MAAM,cAAc,CAAC;AAC/D,YAAY,EAAE,OAAO,IAAI,cAAc,EAAE,MAAM,aAAa,CAAC;AAC7D,YAAY,EAAE,OAAO,IAAI,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AACvE,YAAY,EAAE,OAAO,IAAI,eAAe,EAAE,MAAM,cAAc,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* SIWE (Sign-In with Ethereum) Components
|
|
3
|
+
* EIP-4361 compliant authentication components for Web3 applications
|
|
4
|
+
*/
|
|
5
|
+
export { SIWEProvider, useSIWE } from './SIWEProvider';
|
|
6
|
+
export { SIWEButton } from './SIWEButton';
|
|
7
|
+
export { SIWEModal } from './SIWEModal';
|
|
8
|
+
export { ProtectedRoute } from './ProtectedRoute';
|
|
9
|
+
export { AuthStatus } from './AuthStatus';
|
|
10
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/components/SIWE/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,YAAY,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AACvD,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export { useVarityWallet, type UseVarityWalletReturn } from './useVarityWallet';
|
|
2
|
+
export { useUSDCFormat, type UseUSDCFormatReturn } from './useUSDCFormat';
|
|
3
|
+
export { useAddressValidation, type UseAddressValidationReturn } from './useAddressValidation';
|
|
4
|
+
export { useBlockExplorer, type UseBlockExplorerReturn } from './useBlockExplorer';
|
|
5
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/hooks/web3/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,KAAK,qBAAqB,EAAE,MAAM,mBAAmB,CAAC;AAChF,OAAO,EAAE,aAAa,EAAE,KAAK,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AAC1E,OAAO,EAAE,oBAAoB,EAAE,KAAK,0BAA0B,EAAE,MAAM,wBAAwB,CAAC;AAC/F,OAAO,EAAE,gBAAgB,EAAE,KAAK,sBAAsB,EAAE,MAAM,oBAAoB,CAAC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
// Web3 Hooks
|
|
2
|
+
export { useVarityWallet } from './useVarityWallet';
|
|
3
|
+
export { useUSDCFormat } from './useUSDCFormat';
|
|
4
|
+
export { useAddressValidation } from './useAddressValidation';
|
|
5
|
+
export { useBlockExplorer } from './useBlockExplorer';
|
|
6
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/hooks/web3/index.ts"],"names":[],"mappings":"AAAA,aAAa;AACb,OAAO,EAAE,eAAe,EAA8B,MAAM,mBAAmB,CAAC;AAChF,OAAO,EAAE,aAAa,EAA4B,MAAM,iBAAiB,CAAC;AAC1E,OAAO,EAAE,oBAAoB,EAAmC,MAAM,wBAAwB,CAAC;AAC/F,OAAO,EAAE,gBAAgB,EAA+B,MAAM,oBAAoB,CAAC"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
export interface UseAddressValidationReturn {
|
|
2
|
+
validate: (address: string) => boolean;
|
|
3
|
+
normalize: (address: string) => string | null;
|
|
4
|
+
isValid: (address: string) => boolean;
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* Hook for address validation utilities
|
|
8
|
+
*
|
|
9
|
+
* Provides utilities for validating and normalizing Ethereum addresses:
|
|
10
|
+
* - Validate address format
|
|
11
|
+
* - Normalize address to checksum format
|
|
12
|
+
* - Quick validation check
|
|
13
|
+
*
|
|
14
|
+
* @returns {UseAddressValidationReturn} Address validation utilities
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
* ```tsx
|
|
18
|
+
* import { useAddressValidation } from '@varity-labs/ui-kit';
|
|
19
|
+
*
|
|
20
|
+
* function AddressChecker() {
|
|
21
|
+
* const { validate, normalize } = useAddressValidation();
|
|
22
|
+
*
|
|
23
|
+
* const address = "0x1234...";
|
|
24
|
+
* const isValid = validate(address);
|
|
25
|
+
* const checksumAddress = normalize(address);
|
|
26
|
+
*
|
|
27
|
+
* return (
|
|
28
|
+
* <div>
|
|
29
|
+
* <p>Valid: {isValid ? 'Yes' : 'No'}</p>
|
|
30
|
+
* <p>Checksum: {checksumAddress}</p>
|
|
31
|
+
* </div>
|
|
32
|
+
* );
|
|
33
|
+
* }
|
|
34
|
+
* ```
|
|
35
|
+
*/
|
|
36
|
+
export declare function useAddressValidation(): UseAddressValidationReturn;
|
|
37
|
+
//# sourceMappingURL=useAddressValidation.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useAddressValidation.d.ts","sourceRoot":"","sources":["../../../src/hooks/web3/useAddressValidation.ts"],"names":[],"mappings":"AAGA,MAAM,WAAW,0BAA0B;IACzC,QAAQ,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,OAAO,CAAC;IACvC,SAAS,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,MAAM,GAAG,IAAI,CAAC;IAC9C,OAAO,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,OAAO,CAAC;CACvC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,wBAAgB,oBAAoB,IAAI,0BAA0B,CA4BjE"}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { useMemo, useCallback } from 'react';
|
|
2
|
+
import { isAddress, getAddress } from 'viem';
|
|
3
|
+
/**
|
|
4
|
+
* Hook for address validation utilities
|
|
5
|
+
*
|
|
6
|
+
* Provides utilities for validating and normalizing Ethereum addresses:
|
|
7
|
+
* - Validate address format
|
|
8
|
+
* - Normalize address to checksum format
|
|
9
|
+
* - Quick validation check
|
|
10
|
+
*
|
|
11
|
+
* @returns {UseAddressValidationReturn} Address validation utilities
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* ```tsx
|
|
15
|
+
* import { useAddressValidation } from '@varity-labs/ui-kit';
|
|
16
|
+
*
|
|
17
|
+
* function AddressChecker() {
|
|
18
|
+
* const { validate, normalize } = useAddressValidation();
|
|
19
|
+
*
|
|
20
|
+
* const address = "0x1234...";
|
|
21
|
+
* const isValid = validate(address);
|
|
22
|
+
* const checksumAddress = normalize(address);
|
|
23
|
+
*
|
|
24
|
+
* return (
|
|
25
|
+
* <div>
|
|
26
|
+
* <p>Valid: {isValid ? 'Yes' : 'No'}</p>
|
|
27
|
+
* <p>Checksum: {checksumAddress}</p>
|
|
28
|
+
* </div>
|
|
29
|
+
* );
|
|
30
|
+
* }
|
|
31
|
+
* ```
|
|
32
|
+
*/
|
|
33
|
+
export function useAddressValidation() {
|
|
34
|
+
const validate = useCallback((address) => {
|
|
35
|
+
try {
|
|
36
|
+
return isAddress(address);
|
|
37
|
+
}
|
|
38
|
+
catch {
|
|
39
|
+
return false;
|
|
40
|
+
}
|
|
41
|
+
}, []);
|
|
42
|
+
const normalize = useCallback((address) => {
|
|
43
|
+
try {
|
|
44
|
+
if (!isAddress(address)) {
|
|
45
|
+
return null;
|
|
46
|
+
}
|
|
47
|
+
return getAddress(address);
|
|
48
|
+
}
|
|
49
|
+
catch {
|
|
50
|
+
return null;
|
|
51
|
+
}
|
|
52
|
+
}, []);
|
|
53
|
+
return useMemo(() => ({
|
|
54
|
+
validate,
|
|
55
|
+
normalize,
|
|
56
|
+
isValid: validate,
|
|
57
|
+
}), [validate, normalize]);
|
|
58
|
+
}
|
|
59
|
+
//# sourceMappingURL=useAddressValidation.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useAddressValidation.js","sourceRoot":"","sources":["../../../src/hooks/web3/useAddressValidation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,WAAW,EAAE,MAAM,OAAO,CAAC;AAC7C,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,MAAM,CAAC;AAQ7C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,MAAM,UAAU,oBAAoB;IAClC,MAAM,QAAQ,GAAG,WAAW,CAAC,CAAC,OAAe,EAAW,EAAE;QACxD,IAAI,CAAC;YACH,OAAO,SAAS,CAAC,OAAO,CAAC,CAAC;QAC5B,CAAC;QAAC,MAAM,CAAC;YACP,OAAO,KAAK,CAAC;QACf,CAAC;IACH,CAAC,EAAE,EAAE,CAAC,CAAC;IAEP,MAAM,SAAS,GAAG,WAAW,CAAC,CAAC,OAAe,EAAiB,EAAE;QAC/D,IAAI,CAAC;YACH,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,EAAE,CAAC;gBACxB,OAAO,IAAI,CAAC;YACd,CAAC;YACD,OAAO,UAAU,CAAC,OAAO,CAAC,CAAC;QAC7B,CAAC;QAAC,MAAM,CAAC;YACP,OAAO,IAAI,CAAC;QACd,CAAC;IACH,CAAC,EAAE,EAAE,CAAC,CAAC;IAEP,OAAO,OAAO,CACZ,GAAG,EAAE,CAAC,CAAC;QACL,QAAQ;QACR,SAAS;QACT,OAAO,EAAE,QAAQ;KAClB,CAAC,EACF,CAAC,QAAQ,EAAE,SAAS,CAAC,CACtB,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
export interface UseBlockExplorerReturn {
|
|
2
|
+
getTxUrl: (hash: string, chainId?: number) => string;
|
|
3
|
+
getAddressUrl: (address: string, chainId?: number) => string;
|
|
4
|
+
getBlockUrl: (block: string, chainId?: number) => string;
|
|
5
|
+
openTx: (hash: string, chainId?: number) => void;
|
|
6
|
+
openAddress: (address: string, chainId?: number) => void;
|
|
7
|
+
openBlock: (block: string, chainId?: number) => void;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Hook for block explorer utilities
|
|
11
|
+
*
|
|
12
|
+
* Provides utilities for generating block explorer URLs and opening them:
|
|
13
|
+
* - Get URLs for transactions, addresses, blocks
|
|
14
|
+
* - Open explorer in new tab
|
|
15
|
+
*
|
|
16
|
+
* @returns {UseBlockExplorerReturn} Block explorer utilities
|
|
17
|
+
*
|
|
18
|
+
* @example
|
|
19
|
+
* ```tsx
|
|
20
|
+
* import { useBlockExplorer } from '@varity-labs/ui-kit';
|
|
21
|
+
*
|
|
22
|
+
* function TransactionView() {
|
|
23
|
+
* const { getTxUrl, openTx } = useBlockExplorer();
|
|
24
|
+
*
|
|
25
|
+
* const txHash = "0xabc...";
|
|
26
|
+
* const url = getTxUrl(txHash);
|
|
27
|
+
*
|
|
28
|
+
* return (
|
|
29
|
+
* <button onClick={() => openTx(txHash)}>
|
|
30
|
+
* View on Explorer
|
|
31
|
+
* </button>
|
|
32
|
+
* );
|
|
33
|
+
* }
|
|
34
|
+
* ```
|
|
35
|
+
*/
|
|
36
|
+
export declare function useBlockExplorer(): UseBlockExplorerReturn;
|
|
37
|
+
//# sourceMappingURL=useBlockExplorer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useBlockExplorer.d.ts","sourceRoot":"","sources":["../../../src/hooks/web3/useBlockExplorer.ts"],"names":[],"mappings":"AAGA,MAAM,WAAW,sBAAsB;IACrC,QAAQ,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM,KAAK,MAAM,CAAC;IACrD,aAAa,EAAE,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM,KAAK,MAAM,CAAC;IAC7D,WAAW,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM,KAAK,MAAM,CAAC;IACzD,MAAM,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM,KAAK,IAAI,CAAC;IACjD,WAAW,EAAE,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM,KAAK,IAAI,CAAC;IACzD,SAAS,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM,KAAK,IAAI,CAAC;CACtD;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,wBAAgB,gBAAgB,IAAI,sBAAsB,CAwDzD"}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { useMemo, useCallback } from 'react';
|
|
2
|
+
import { getBlockExplorerUrl, DEFAULT_CHAIN } from '../../config/chains';
|
|
3
|
+
/**
|
|
4
|
+
* Hook for block explorer utilities
|
|
5
|
+
*
|
|
6
|
+
* Provides utilities for generating block explorer URLs and opening them:
|
|
7
|
+
* - Get URLs for transactions, addresses, blocks
|
|
8
|
+
* - Open explorer in new tab
|
|
9
|
+
*
|
|
10
|
+
* @returns {UseBlockExplorerReturn} Block explorer utilities
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* ```tsx
|
|
14
|
+
* import { useBlockExplorer } from '@varity-labs/ui-kit';
|
|
15
|
+
*
|
|
16
|
+
* function TransactionView() {
|
|
17
|
+
* const { getTxUrl, openTx } = useBlockExplorer();
|
|
18
|
+
*
|
|
19
|
+
* const txHash = "0xabc...";
|
|
20
|
+
* const url = getTxUrl(txHash);
|
|
21
|
+
*
|
|
22
|
+
* return (
|
|
23
|
+
* <button onClick={() => openTx(txHash)}>
|
|
24
|
+
* View on Explorer
|
|
25
|
+
* </button>
|
|
26
|
+
* );
|
|
27
|
+
* }
|
|
28
|
+
* ```
|
|
29
|
+
*/
|
|
30
|
+
export function useBlockExplorer() {
|
|
31
|
+
const defaultChainId = DEFAULT_CHAIN.id;
|
|
32
|
+
const getTxUrl = useCallback((hash, chainId = defaultChainId) => {
|
|
33
|
+
return getBlockExplorerUrl(chainId, 'tx', hash);
|
|
34
|
+
}, [defaultChainId]);
|
|
35
|
+
const getAddressUrl = useCallback((address, chainId = defaultChainId) => {
|
|
36
|
+
return getBlockExplorerUrl(chainId, 'address', address);
|
|
37
|
+
}, [defaultChainId]);
|
|
38
|
+
const getBlockUrl = useCallback((block, chainId = defaultChainId) => {
|
|
39
|
+
return getBlockExplorerUrl(chainId, 'block', block);
|
|
40
|
+
}, [defaultChainId]);
|
|
41
|
+
const openTx = useCallback((hash, chainId = defaultChainId) => {
|
|
42
|
+
window.open(getTxUrl(hash, chainId), '_blank');
|
|
43
|
+
}, [getTxUrl, defaultChainId]);
|
|
44
|
+
const openAddress = useCallback((address, chainId = defaultChainId) => {
|
|
45
|
+
window.open(getAddressUrl(address, chainId), '_blank');
|
|
46
|
+
}, [getAddressUrl, defaultChainId]);
|
|
47
|
+
const openBlock = useCallback((block, chainId = defaultChainId) => {
|
|
48
|
+
window.open(getBlockUrl(block, chainId), '_blank');
|
|
49
|
+
}, [getBlockUrl, defaultChainId]);
|
|
50
|
+
return useMemo(() => ({
|
|
51
|
+
getTxUrl,
|
|
52
|
+
getAddressUrl,
|
|
53
|
+
getBlockUrl,
|
|
54
|
+
openTx,
|
|
55
|
+
openAddress,
|
|
56
|
+
openBlock,
|
|
57
|
+
}), [getTxUrl, getAddressUrl, getBlockUrl, openTx, openAddress, openBlock]);
|
|
58
|
+
}
|
|
59
|
+
//# sourceMappingURL=useBlockExplorer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useBlockExplorer.js","sourceRoot":"","sources":["../../../src/hooks/web3/useBlockExplorer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,WAAW,EAAE,MAAM,OAAO,CAAC;AAC7C,OAAO,EAAE,mBAAmB,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAWzE;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,MAAM,UAAU,gBAAgB;IAC9B,MAAM,cAAc,GAAG,aAAa,CAAC,EAAE,CAAC;IAExC,MAAM,QAAQ,GAAG,WAAW,CAC1B,CAAC,IAAY,EAAE,OAAO,GAAG,cAAc,EAAE,EAAE;QACzC,OAAO,mBAAmB,CAAC,OAAO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,EAAE,CAAC,CAAC;QACL,QAAQ;QACR,aAAa;QACb,WAAW;QACX,MAAM;QACN,WAAW;QACX,SAAS;KACV,CAAC,EACF,CAAC,QAAQ,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,EAAE,WAAW,EAAE,SAAS,CAAC,CACvE,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
export interface UseUSDCFormatReturn {
|
|
2
|
+
format: (amount: bigint | string | number, decimals?: number) => string;
|
|
3
|
+
parse: (amount: string | number) => bigint;
|
|
4
|
+
decimals: number;
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* Hook for USDC formatting utilities
|
|
8
|
+
*
|
|
9
|
+
* Provides utilities for formatting and parsing USDC amounts with 6 decimals:
|
|
10
|
+
* - Format bigint to human-readable string
|
|
11
|
+
* - Parse string to bigint
|
|
12
|
+
* - Access USDC decimals constant
|
|
13
|
+
*
|
|
14
|
+
* @returns {UseUSDCFormatReturn} USDC formatting utilities
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
* ```tsx
|
|
18
|
+
* import { useUSDCFormat } from '@varity-labs/ui-kit';
|
|
19
|
+
*
|
|
20
|
+
* function BalanceCard() {
|
|
21
|
+
* const { format, parse, decimals } = useUSDCFormat();
|
|
22
|
+
*
|
|
23
|
+
* const balance = BigInt(1500000000); // 1500 USDC
|
|
24
|
+
* const formatted = format(balance, 2); // "1500.00"
|
|
25
|
+
*
|
|
26
|
+
* const amount = "100.50";
|
|
27
|
+
* const parsed = parse(amount); // BigInt(100500000)
|
|
28
|
+
*
|
|
29
|
+
* return <div>Balance: {formatted} USDC</div>;
|
|
30
|
+
* }
|
|
31
|
+
* ```
|
|
32
|
+
*/
|
|
33
|
+
export declare function useUSDCFormat(): UseUSDCFormatReturn;
|
|
34
|
+
//# sourceMappingURL=useUSDCFormat.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useUSDCFormat.d.ts","sourceRoot":"","sources":["../../../src/hooks/web3/useUSDCFormat.ts"],"names":[],"mappings":"AAGA,MAAM,WAAW,mBAAmB;IAClC,MAAM,EAAE,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,EAAE,QAAQ,CAAC,EAAE,MAAM,KAAK,MAAM,CAAC;IACxE,KAAK,EAAE,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,KAAK,MAAM,CAAC;IAC3C,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,wBAAgB,aAAa,IAAI,mBAAmB,CAiBnD"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { useMemo, useCallback } from 'react';
|
|
2
|
+
import { formatUSDC, parseUSDC, USDC_DECIMALS } from '../../config/chains';
|
|
3
|
+
/**
|
|
4
|
+
* Hook for USDC formatting utilities
|
|
5
|
+
*
|
|
6
|
+
* Provides utilities for formatting and parsing USDC amounts with 6 decimals:
|
|
7
|
+
* - Format bigint to human-readable string
|
|
8
|
+
* - Parse string to bigint
|
|
9
|
+
* - Access USDC decimals constant
|
|
10
|
+
*
|
|
11
|
+
* @returns {UseUSDCFormatReturn} USDC formatting utilities
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* ```tsx
|
|
15
|
+
* import { useUSDCFormat } from '@varity-labs/ui-kit';
|
|
16
|
+
*
|
|
17
|
+
* function BalanceCard() {
|
|
18
|
+
* const { format, parse, decimals } = useUSDCFormat();
|
|
19
|
+
*
|
|
20
|
+
* const balance = BigInt(1500000000); // 1500 USDC
|
|
21
|
+
* const formatted = format(balance, 2); // "1500.00"
|
|
22
|
+
*
|
|
23
|
+
* const amount = "100.50";
|
|
24
|
+
* const parsed = parse(amount); // BigInt(100500000)
|
|
25
|
+
*
|
|
26
|
+
* return <div>Balance: {formatted} USDC</div>;
|
|
27
|
+
* }
|
|
28
|
+
* ```
|
|
29
|
+
*/
|
|
30
|
+
export function useUSDCFormat() {
|
|
31
|
+
const format = useCallback((amount, decimals = 2) => {
|
|
32
|
+
return formatUSDC(amount, decimals);
|
|
33
|
+
}, []);
|
|
34
|
+
const parse = useCallback((amount) => {
|
|
35
|
+
return parseUSDC(amount);
|
|
36
|
+
}, []);
|
|
37
|
+
return useMemo(() => ({
|
|
38
|
+
format,
|
|
39
|
+
parse,
|
|
40
|
+
decimals: USDC_DECIMALS,
|
|
41
|
+
}), [format, parse]);
|
|
42
|
+
}
|
|
43
|
+
//# sourceMappingURL=useUSDCFormat.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useUSDCFormat.js","sourceRoot":"","sources":["../../../src/hooks/web3/useUSDCFormat.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,WAAW,EAAE,MAAM,OAAO,CAAC;AAC7C,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAQ3E;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,MAAM,UAAU,aAAa;IAC3B,MAAM,MAAM,GAAG,WAAW,CAAC,CAAC,MAAgC,EAAE,QAAQ,GAAG,CAAC,EAAE,EAAE;QAC5E,OAAO,UAAU,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC;IACtC,CAAC,EAAE,EAAE,CAAC,CAAC;IAEP,MAAM,KAAK,GAAG,WAAW,CAAC,CAAC,MAAuB,EAAE,EAAE;QACpD,OAAO,SAAS,CAAC,MAAM,CAAC,CAAC;IAC3B,CAAC,EAAE,EAAE,CAAC,CAAC;IAEP,OAAO,OAAO,CACZ,GAAG,EAAE,CAAC,CAAC;QACL,MAAM;QACN,KAAK;QACL,QAAQ,EAAE,aAAa;KACxB,CAAC,EACF,CAAC,MAAM,EAAE,KAAK,CAAC,CAChB,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
export interface UseVarityWalletReturn {
|
|
2
|
+
address: string | null;
|
|
3
|
+
formattedAddress: string | null;
|
|
4
|
+
isConnected: boolean;
|
|
5
|
+
disconnect: () => Promise<void>;
|
|
6
|
+
balance: bigint | null;
|
|
7
|
+
isLoadingBalance: boolean;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Hook for wallet operations
|
|
11
|
+
*
|
|
12
|
+
* Provides convenient access to wallet state and operations:
|
|
13
|
+
* - Current address and formatted address
|
|
14
|
+
* - Connection status
|
|
15
|
+
* - Disconnect function
|
|
16
|
+
* - Balance queries
|
|
17
|
+
*
|
|
18
|
+
* @returns {UseVarityWalletReturn} Wallet state and operations
|
|
19
|
+
*
|
|
20
|
+
* @example
|
|
21
|
+
* ```tsx
|
|
22
|
+
* import { useVarityWallet } from '@varity-labs/ui-kit';
|
|
23
|
+
*
|
|
24
|
+
* function MyComponent() {
|
|
25
|
+
* const {
|
|
26
|
+
* address,
|
|
27
|
+
* formattedAddress,
|
|
28
|
+
* isConnected,
|
|
29
|
+
* disconnect,
|
|
30
|
+
* balance
|
|
31
|
+
* } = useVarityWallet();
|
|
32
|
+
*
|
|
33
|
+
* if (!isConnected) {
|
|
34
|
+
* return <ConnectWallet />;
|
|
35
|
+
* }
|
|
36
|
+
*
|
|
37
|
+
* return (
|
|
38
|
+
* <div>
|
|
39
|
+
* <p>Address: {formattedAddress}</p>
|
|
40
|
+
* <p>Balance: {balance?.toString()} USDC</p>
|
|
41
|
+
* <button onClick={disconnect}>Disconnect</button>
|
|
42
|
+
* </div>
|
|
43
|
+
* );
|
|
44
|
+
* }
|
|
45
|
+
* ```
|
|
46
|
+
*/
|
|
47
|
+
export declare function useVarityWallet(): UseVarityWalletReturn;
|
|
48
|
+
//# sourceMappingURL=useVarityWallet.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useVarityWallet.d.ts","sourceRoot":"","sources":["../../../src/hooks/web3/useVarityWallet.ts"],"names":[],"mappings":"AAKA,MAAM,WAAW,qBAAqB;IACpC,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;IACvB,gBAAgB,EAAE,MAAM,GAAG,IAAI,CAAC;IAChC,WAAW,EAAE,OAAO,CAAC;IACrB,UAAU,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;IAChC,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;IACvB,gBAAgB,EAAE,OAAO,CAAC;CAC3B;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqCG;AACH,wBAAgB,eAAe,IAAI,qBAAqB,CAkCvD"}
|