signer-test-sdk-react 0.0.1
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 +114 -0
- package/dist/src/AbstraxnProvider.d.ts +20 -0
- package/dist/src/AbstraxnProvider.js +2213 -0
- package/dist/src/AbstraxnProvider.js.map +1 -0
- package/dist/src/ConnectButton.css +217 -0
- package/dist/src/ConnectButton.d.ts +71 -0
- package/dist/src/ConnectButton.js +102 -0
- package/dist/src/ConnectButton.js.map +1 -0
- package/dist/src/ExternalWalletButtons.css +319 -0
- package/dist/src/ExternalWalletButtons.d.ts +56 -0
- package/dist/src/ExternalWalletButtons.js +245 -0
- package/dist/src/ExternalWalletButtons.js.map +1 -0
- package/dist/src/OnboardingUI.d.ts +63 -0
- package/dist/src/OnboardingUI.js +66 -0
- package/dist/src/OnboardingUI.js.map +1 -0
- package/dist/src/WalletModal.css +549 -0
- package/dist/src/WalletModal.d.ts +6 -0
- package/dist/src/WalletModal.js +89 -0
- package/dist/src/WalletModal.js.map +1 -0
- package/dist/src/components/OnboardingUI/OnboardingUI.css +727 -0
- package/dist/src/components/OnboardingUI/OnboardingUIReact.d.ts +15 -0
- package/dist/src/components/OnboardingUI/OnboardingUIReact.js +65 -0
- package/dist/src/components/OnboardingUI/OnboardingUIReact.js.map +1 -0
- package/dist/src/components/OnboardingUI/OnboardingUIWeb.d.ts +257 -0
- package/dist/src/components/OnboardingUI/OnboardingUIWeb.js +3454 -0
- package/dist/src/components/OnboardingUI/OnboardingUIWeb.js.map +1 -0
- package/dist/src/components/OnboardingUI/components/EmailForm.d.ts +16 -0
- package/dist/src/components/OnboardingUI/components/EmailForm.js +19 -0
- package/dist/src/components/OnboardingUI/components/EmailForm.js.map +1 -0
- package/dist/src/components/OnboardingUI/components/Modal.d.ts +15 -0
- package/dist/src/components/OnboardingUI/components/Modal.js +68 -0
- package/dist/src/components/OnboardingUI/components/Modal.js.map +1 -0
- package/dist/src/components/OnboardingUI/components/OtpForm.d.ts +19 -0
- package/dist/src/components/OnboardingUI/components/OtpForm.js +58 -0
- package/dist/src/components/OnboardingUI/components/OtpForm.js.map +1 -0
- package/dist/src/components/OnboardingUI/components/PasskeyButton.d.ts +14 -0
- package/dist/src/components/OnboardingUI/components/PasskeyButton.js +22 -0
- package/dist/src/components/OnboardingUI/components/PasskeyButton.js.map +1 -0
- package/dist/src/components/OnboardingUI/components/SocialButtons.d.ts +15 -0
- package/dist/src/components/OnboardingUI/components/SocialButtons.js +15 -0
- package/dist/src/components/OnboardingUI/components/SocialButtons.js.map +1 -0
- package/dist/src/components/OnboardingUI/components/index.d.ts +13 -0
- package/dist/src/components/OnboardingUI/components/index.js +9 -0
- package/dist/src/components/OnboardingUI/components/index.js.map +1 -0
- package/dist/src/components/OnboardingUI/hooks/index.d.ts +7 -0
- package/dist/src/components/OnboardingUI/hooks/index.js +6 -0
- package/dist/src/components/OnboardingUI/hooks/index.js.map +1 -0
- package/dist/src/components/OnboardingUI/hooks/useAuthMethods.d.ts +11 -0
- package/dist/src/components/OnboardingUI/hooks/useAuthMethods.js +146 -0
- package/dist/src/components/OnboardingUI/hooks/useAuthMethods.js.map +1 -0
- package/dist/src/components/OnboardingUI/hooks/useOnboarding.d.ts +21 -0
- package/dist/src/components/OnboardingUI/hooks/useOnboarding.js +135 -0
- package/dist/src/components/OnboardingUI/hooks/useOnboarding.js.map +1 -0
- package/dist/src/components/OnboardingUI/index.d.ts +12 -0
- package/dist/src/components/OnboardingUI/index.js +15 -0
- package/dist/src/components/OnboardingUI/index.js.map +1 -0
- package/dist/src/hooks.d.ts +204 -0
- package/dist/src/hooks.js +394 -0
- package/dist/src/hooks.js.map +1 -0
- package/dist/src/index.d.ts +14 -0
- package/dist/src/index.js +11 -0
- package/dist/src/index.js.map +1 -0
- package/dist/src/types.d.ts +181 -0
- package/dist/src/types.js +2 -0
- package/dist/src/types.js.map +1 -0
- package/dist/src/wagmiConfig.d.ts +147 -0
- package/dist/src/wagmiConfig.js +81 -0
- package/dist/src/wagmiConfig.js.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -0
- package/package.json +68 -0
|
@@ -0,0 +1,394 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* React Hooks for Abstraxn Wallet SDK
|
|
3
|
+
*/
|
|
4
|
+
import { useState, useCallback, useEffect } from 'react';
|
|
5
|
+
import { useAbstraxnWallet } from './AbstraxnProvider';
|
|
6
|
+
/**
|
|
7
|
+
* Hook to check if wallet is connected
|
|
8
|
+
*/
|
|
9
|
+
export function useIsConnected() {
|
|
10
|
+
const { isConnected } = useAbstraxnWallet();
|
|
11
|
+
return isConnected;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Hook to get wallet address
|
|
15
|
+
*/
|
|
16
|
+
export function useAddress() {
|
|
17
|
+
const { address } = useAbstraxnWallet();
|
|
18
|
+
return address;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Hook to get current user and whoami information
|
|
22
|
+
* Returns an object with both user and whoami data
|
|
23
|
+
*/
|
|
24
|
+
export function useUser() {
|
|
25
|
+
const { user, whoami } = useAbstraxnWallet();
|
|
26
|
+
return { user, whoami };
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Hook to get current chain ID
|
|
30
|
+
*/
|
|
31
|
+
export function useChainId() {
|
|
32
|
+
const { chainId } = useAbstraxnWallet();
|
|
33
|
+
return chainId;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Hook to check if wallet is initialized
|
|
37
|
+
*/
|
|
38
|
+
export function useIsInitialized() {
|
|
39
|
+
const { isInitialized } = useAbstraxnWallet();
|
|
40
|
+
return isInitialized;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Hook to get loading state
|
|
44
|
+
*/
|
|
45
|
+
export function useLoading() {
|
|
46
|
+
const { loading } = useAbstraxnWallet();
|
|
47
|
+
return loading;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Hook to get error state
|
|
51
|
+
*/
|
|
52
|
+
export function useError() {
|
|
53
|
+
const { error } = useAbstraxnWallet();
|
|
54
|
+
return error;
|
|
55
|
+
}
|
|
56
|
+
// Re-export core hook for modules that import from './hooks'
|
|
57
|
+
export { useAbstraxnWallet } from './AbstraxnProvider';
|
|
58
|
+
/**
|
|
59
|
+
* Hook to get wallet instance (for advanced usage)
|
|
60
|
+
*/
|
|
61
|
+
export function useWallet() {
|
|
62
|
+
const { wallet } = useAbstraxnWallet();
|
|
63
|
+
return wallet;
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Hook to prepare and sign transaction
|
|
67
|
+
* Prepares the unsigned transaction, calls the sign API, and returns the signed transaction
|
|
68
|
+
* User can execute this signed transaction themselves
|
|
69
|
+
*/
|
|
70
|
+
export function usePrepareTransaction() {
|
|
71
|
+
const { wallet, isConnected, address, signTransactionViaAPI } = useAbstraxnWallet();
|
|
72
|
+
const prepareTransaction = async (to, value, rpcUrl, chainId) => {
|
|
73
|
+
if (!isConnected || !wallet || !address) {
|
|
74
|
+
throw new Error('Wallet is not connected');
|
|
75
|
+
}
|
|
76
|
+
// Import viem functions dynamically
|
|
77
|
+
const { createPublicClient, http, serializeTransaction } = await import('viem');
|
|
78
|
+
const { polygonAmoy } = await import('viem/chains');
|
|
79
|
+
const targetRpcUrl = rpcUrl || 'https://rpc-amoy.polygon.technology';
|
|
80
|
+
const targetChainId = chainId || polygonAmoy.id;
|
|
81
|
+
// Create public client
|
|
82
|
+
const publicClient = createPublicClient({
|
|
83
|
+
chain: polygonAmoy,
|
|
84
|
+
transport: http(targetRpcUrl),
|
|
85
|
+
});
|
|
86
|
+
// Get nonce
|
|
87
|
+
const nonce = await publicClient.getTransactionCount({ address: address });
|
|
88
|
+
// Get gas price
|
|
89
|
+
const gasPrice = await publicClient.getGasPrice();
|
|
90
|
+
// Convert amount to wei (18 decimals)
|
|
91
|
+
const valueInWei = BigInt(Math.floor(Number(value) * 10 ** 18));
|
|
92
|
+
// Create unsigned transaction
|
|
93
|
+
const unsignedTx = {
|
|
94
|
+
to: to,
|
|
95
|
+
value: valueInWei,
|
|
96
|
+
gas: 21000n,
|
|
97
|
+
nonce: nonce,
|
|
98
|
+
gasPrice: gasPrice,
|
|
99
|
+
chainId: targetChainId,
|
|
100
|
+
data: '0x',
|
|
101
|
+
};
|
|
102
|
+
// Serialize transaction
|
|
103
|
+
const serializedTx = serializeTransaction(unsignedTx);
|
|
104
|
+
// Sign transaction via API
|
|
105
|
+
const signResult = await signTransactionViaAPI(serializedTx, address);
|
|
106
|
+
return {
|
|
107
|
+
unsignedTransaction: serializedTx,
|
|
108
|
+
signedTransaction: signResult.signedTransaction,
|
|
109
|
+
};
|
|
110
|
+
};
|
|
111
|
+
return { prepareTransaction, isConnected, address };
|
|
112
|
+
}
|
|
113
|
+
/**
|
|
114
|
+
* Hook to sign transaction via API
|
|
115
|
+
* Returns the signed transaction that user can execute themselves
|
|
116
|
+
*/
|
|
117
|
+
export function useSignTransaction() {
|
|
118
|
+
const { wallet, isConnected, address, signTransactionViaAPI } = useAbstraxnWallet();
|
|
119
|
+
const signTransaction = async (unsignedTransaction, fromAddress) => {
|
|
120
|
+
if (!isConnected || !wallet) {
|
|
121
|
+
throw new Error('Wallet is not connected');
|
|
122
|
+
}
|
|
123
|
+
const targetAddress = fromAddress || address;
|
|
124
|
+
if (!targetAddress) {
|
|
125
|
+
throw new Error('Address is required');
|
|
126
|
+
}
|
|
127
|
+
return await signTransactionViaAPI(unsignedTransaction, targetAddress);
|
|
128
|
+
};
|
|
129
|
+
return { signTransaction, isConnected, address };
|
|
130
|
+
}
|
|
131
|
+
/**
|
|
132
|
+
* Hook to sign and send transaction
|
|
133
|
+
* Signs transaction via API and then executes it internally
|
|
134
|
+
* Returns transaction hash
|
|
135
|
+
*/
|
|
136
|
+
export function useSignAndSendTransaction() {
|
|
137
|
+
const { wallet, isConnected, address, signAndSendTransaction } = useAbstraxnWallet();
|
|
138
|
+
const signAndSend = async (unsignedTransaction, fromAddress, rpcUrl) => {
|
|
139
|
+
if (!isConnected || !wallet) {
|
|
140
|
+
throw new Error('Wallet is not connected');
|
|
141
|
+
}
|
|
142
|
+
const targetAddress = fromAddress || address;
|
|
143
|
+
if (!targetAddress) {
|
|
144
|
+
throw new Error('Address is required');
|
|
145
|
+
}
|
|
146
|
+
return await signAndSendTransaction(unsignedTransaction, targetAddress, rpcUrl);
|
|
147
|
+
};
|
|
148
|
+
return { signAndSendTransaction: signAndSend, isConnected, address };
|
|
149
|
+
}
|
|
150
|
+
/**
|
|
151
|
+
* Hook to export wallet private key
|
|
152
|
+
* Returns the export bundle containing the private key
|
|
153
|
+
* Automatically picks the connected wallet address (EVM or Solana) from whoami
|
|
154
|
+
*/
|
|
155
|
+
export function useExportWallet() {
|
|
156
|
+
const { wallet, isConnected, address } = useAbstraxnWallet();
|
|
157
|
+
const exportWallet = async (targetPublicKey, privateKey, blockchain) => {
|
|
158
|
+
if (!isConnected || !wallet) {
|
|
159
|
+
throw new Error('Wallet is not connected');
|
|
160
|
+
}
|
|
161
|
+
// Pass blockchain type to wallet.exportWallet, which will load address from whoami
|
|
162
|
+
return await wallet.exportWallet(targetPublicKey, privateKey, blockchain);
|
|
163
|
+
};
|
|
164
|
+
return { exportWallet, isConnected, address };
|
|
165
|
+
}
|
|
166
|
+
/**
|
|
167
|
+
* Hook to call whoami API
|
|
168
|
+
* Returns whoami data, loading state, error, and a refresh function
|
|
169
|
+
*
|
|
170
|
+
* @example
|
|
171
|
+
* ```tsx
|
|
172
|
+
* const { whoami, loading, error, refreshWhoami } = useWhoami();
|
|
173
|
+
*
|
|
174
|
+
* useEffect(() => {
|
|
175
|
+
* refreshWhoami();
|
|
176
|
+
* }, []);
|
|
177
|
+
* ```
|
|
178
|
+
*/
|
|
179
|
+
export function useWhoami() {
|
|
180
|
+
const { isConnected, whoami: cachedWhoami, refreshWhoami: refreshWhoamiFromContext, loading: contextLoading, error: contextError } = useAbstraxnWallet();
|
|
181
|
+
const [whoami, setWhoami] = useState(cachedWhoami);
|
|
182
|
+
const [loading, setLoading] = useState(false);
|
|
183
|
+
const [error, setError] = useState(null);
|
|
184
|
+
const refreshWhoami = useCallback(async () => {
|
|
185
|
+
if (!isConnected) {
|
|
186
|
+
setError(new Error('Wallet is not connected'));
|
|
187
|
+
return null;
|
|
188
|
+
}
|
|
189
|
+
setLoading(true);
|
|
190
|
+
setError(null);
|
|
191
|
+
try {
|
|
192
|
+
// Use refreshWhoami from context which updates both API and context state
|
|
193
|
+
// This will handle the check for external wallets and connection status internally
|
|
194
|
+
const whoamiData = await refreshWhoamiFromContext();
|
|
195
|
+
setWhoami(whoamiData);
|
|
196
|
+
return whoamiData;
|
|
197
|
+
}
|
|
198
|
+
catch (err) {
|
|
199
|
+
// Don't throw error if wallet is not connected (might be during disconnect)
|
|
200
|
+
const error = err instanceof Error ? err : new Error('Failed to refresh whoami information');
|
|
201
|
+
// Only set error if it's not a connection error
|
|
202
|
+
if (!error.message.includes('not connected') && !error.message.includes('Wallet is not connected')) {
|
|
203
|
+
setError(error);
|
|
204
|
+
}
|
|
205
|
+
return null;
|
|
206
|
+
}
|
|
207
|
+
finally {
|
|
208
|
+
setLoading(false);
|
|
209
|
+
}
|
|
210
|
+
}, [isConnected, refreshWhoamiFromContext]);
|
|
211
|
+
// Update whoami when cached value changes
|
|
212
|
+
useEffect(() => {
|
|
213
|
+
if (cachedWhoami) {
|
|
214
|
+
setWhoami(cachedWhoami);
|
|
215
|
+
}
|
|
216
|
+
}, [cachedWhoami]);
|
|
217
|
+
// Use context loading/error if hook is not in loading state
|
|
218
|
+
const displayLoading = loading || contextLoading;
|
|
219
|
+
const displayError = error || contextError;
|
|
220
|
+
return {
|
|
221
|
+
whoami,
|
|
222
|
+
loading: displayLoading,
|
|
223
|
+
error: displayError,
|
|
224
|
+
refreshWhoami,
|
|
225
|
+
isConnected,
|
|
226
|
+
};
|
|
227
|
+
}
|
|
228
|
+
/**
|
|
229
|
+
* Hook to access external wallet functionality
|
|
230
|
+
* Returns external wallet connection state and methods
|
|
231
|
+
*/
|
|
232
|
+
export function useExternalWallet() {
|
|
233
|
+
const { connectExternalWallet, disconnectExternalWallet, isExternalWalletConnected, externalWalletAddress, externalWalletChainId, externalWalletBalance, externalWalletNetwork, availableConnectors, switchExternalWalletChain, } = useAbstraxnWallet();
|
|
234
|
+
return {
|
|
235
|
+
connectExternalWallet: connectExternalWallet || (async () => {
|
|
236
|
+
throw new Error('External wallets are not enabled');
|
|
237
|
+
}),
|
|
238
|
+
disconnectExternalWallet: disconnectExternalWallet || (async () => {
|
|
239
|
+
throw new Error('External wallets are not enabled');
|
|
240
|
+
}),
|
|
241
|
+
isExternalWalletConnected: isExternalWalletConnected ?? false,
|
|
242
|
+
externalWalletAddress: externalWalletAddress ?? null,
|
|
243
|
+
externalWalletChainId: externalWalletChainId ?? null,
|
|
244
|
+
externalWalletBalance: externalWalletBalance ?? null,
|
|
245
|
+
externalWalletNetwork: externalWalletNetwork ?? null,
|
|
246
|
+
availableConnectors: availableConnectors ?? [],
|
|
247
|
+
switchExternalWalletChain: switchExternalWalletChain || (async () => {
|
|
248
|
+
throw new Error('External wallets are not enabled');
|
|
249
|
+
}),
|
|
250
|
+
};
|
|
251
|
+
}
|
|
252
|
+
/**
|
|
253
|
+
* Hook to get external wallet balance
|
|
254
|
+
* Returns balance in wei (BigInt) and formatted balance
|
|
255
|
+
*/
|
|
256
|
+
export function useExternalWalletBalance() {
|
|
257
|
+
const { externalWalletBalance, externalWalletAddress, isExternalWalletConnected } = useExternalWallet();
|
|
258
|
+
const [formattedBalance, setFormattedBalance] = useState('0');
|
|
259
|
+
useEffect(() => {
|
|
260
|
+
if (externalWalletBalance && externalWalletBalance > 0n) {
|
|
261
|
+
// Convert from wei to ETH (18 decimals)
|
|
262
|
+
const balanceInEth = Number(externalWalletBalance) / 1e18;
|
|
263
|
+
setFormattedBalance(balanceInEth.toFixed(6));
|
|
264
|
+
}
|
|
265
|
+
else {
|
|
266
|
+
setFormattedBalance('0');
|
|
267
|
+
}
|
|
268
|
+
}, [externalWalletBalance]);
|
|
269
|
+
return {
|
|
270
|
+
balance: externalWalletBalance,
|
|
271
|
+
formattedBalance,
|
|
272
|
+
address: externalWalletAddress,
|
|
273
|
+
isConnected: isExternalWalletConnected,
|
|
274
|
+
};
|
|
275
|
+
}
|
|
276
|
+
/**
|
|
277
|
+
* Hook to get external wallet chain information
|
|
278
|
+
* Returns chainId, network name, and switch chain function
|
|
279
|
+
*/
|
|
280
|
+
export function useExternalWalletChain() {
|
|
281
|
+
const { externalWalletChainId, externalWalletNetwork, switchExternalWalletChain, isExternalWalletConnected } = useExternalWallet();
|
|
282
|
+
return {
|
|
283
|
+
chainId: externalWalletChainId,
|
|
284
|
+
network: externalWalletNetwork,
|
|
285
|
+
switchChain: switchExternalWalletChain,
|
|
286
|
+
isConnected: isExternalWalletConnected,
|
|
287
|
+
};
|
|
288
|
+
}
|
|
289
|
+
/**
|
|
290
|
+
* Comprehensive hook for external wallet information
|
|
291
|
+
* Returns chainId, network, balance, switchChain function, connection status, and walletClient
|
|
292
|
+
* This is the main hook to use for external wallet operations
|
|
293
|
+
*
|
|
294
|
+
* @example
|
|
295
|
+
* ```tsx
|
|
296
|
+
* const { chainId, network, balance, formattedBalance, switchChain, isConnected, address, walletClient } = useExternalWalletInfo();
|
|
297
|
+
*
|
|
298
|
+
* // Switch chain
|
|
299
|
+
* await switchChain(137); // Switch to Polygon
|
|
300
|
+
*
|
|
301
|
+
* // Send transaction using walletClient
|
|
302
|
+
* const txHash = await walletClient.sendTransaction({
|
|
303
|
+
* to: '0x...',
|
|
304
|
+
* value: '0.1',
|
|
305
|
+
* });
|
|
306
|
+
*
|
|
307
|
+
* // Sign message using walletClient
|
|
308
|
+
* const signature = await walletClient.signMessage('Hello World');
|
|
309
|
+
*
|
|
310
|
+
* // Display info
|
|
311
|
+
* <div>
|
|
312
|
+
* <p>Network: {network}</p>
|
|
313
|
+
* <p>Balance: {formattedBalance} ETH</p>
|
|
314
|
+
* </div>
|
|
315
|
+
* ```
|
|
316
|
+
*/
|
|
317
|
+
export function useExternalWalletInfo() {
|
|
318
|
+
const { externalWalletChainId, externalWalletNetwork, switchExternalWalletChain, isExternalWalletConnected, externalWalletAddress, externalWalletBalance, } = useExternalWallet();
|
|
319
|
+
const { sendTransaction, signMessage, signTransaction, switchChain, } = useAbstraxnWallet();
|
|
320
|
+
const [formattedBalance, setFormattedBalance] = useState('0');
|
|
321
|
+
useEffect(() => {
|
|
322
|
+
if (externalWalletBalance && externalWalletBalance > 0n) {
|
|
323
|
+
// Convert from wei to ETH (18 decimals)
|
|
324
|
+
const balanceInEth = Number(externalWalletBalance) / 1e18;
|
|
325
|
+
setFormattedBalance(balanceInEth.toFixed(6));
|
|
326
|
+
}
|
|
327
|
+
else {
|
|
328
|
+
setFormattedBalance('0');
|
|
329
|
+
}
|
|
330
|
+
}, [externalWalletBalance]);
|
|
331
|
+
// Create walletClient object for external wallet transactions
|
|
332
|
+
const walletClient = {
|
|
333
|
+
/**
|
|
334
|
+
* Send a transaction using external wallet
|
|
335
|
+
* @param tx - Transaction request object
|
|
336
|
+
* @returns Promise resolving to transaction response with hash
|
|
337
|
+
*/
|
|
338
|
+
sendTransaction: async (tx) => {
|
|
339
|
+
if (!isExternalWalletConnected) {
|
|
340
|
+
throw new Error('External wallet is not connected');
|
|
341
|
+
}
|
|
342
|
+
return await sendTransaction(tx);
|
|
343
|
+
},
|
|
344
|
+
/**
|
|
345
|
+
* Sign a message using external wallet
|
|
346
|
+
* @param message - Message string to sign
|
|
347
|
+
* @returns Promise resolving to signature string
|
|
348
|
+
*/
|
|
349
|
+
signMessage: async (message) => {
|
|
350
|
+
if (!isExternalWalletConnected) {
|
|
351
|
+
throw new Error('External wallet is not connected');
|
|
352
|
+
}
|
|
353
|
+
return await signMessage(message);
|
|
354
|
+
},
|
|
355
|
+
/**
|
|
356
|
+
* Sign a transaction using external wallet
|
|
357
|
+
* @param tx - Transaction request object
|
|
358
|
+
* @returns Promise resolving to signed transaction string
|
|
359
|
+
*/
|
|
360
|
+
signTransaction: async (tx) => {
|
|
361
|
+
if (!isExternalWalletConnected) {
|
|
362
|
+
throw new Error('External wallet is not connected');
|
|
363
|
+
}
|
|
364
|
+
return await signTransaction(tx);
|
|
365
|
+
},
|
|
366
|
+
/**
|
|
367
|
+
* Switch chain on external wallet
|
|
368
|
+
* @param chainId - Chain ID to switch to
|
|
369
|
+
* @returns Promise that resolves when chain is switched
|
|
370
|
+
*/
|
|
371
|
+
switchChain: async (chainId) => {
|
|
372
|
+
if (!isExternalWalletConnected) {
|
|
373
|
+
throw new Error('External wallet is not connected');
|
|
374
|
+
}
|
|
375
|
+
return await switchChain(chainId);
|
|
376
|
+
},
|
|
377
|
+
};
|
|
378
|
+
return {
|
|
379
|
+
// Chain information
|
|
380
|
+
chainId: externalWalletChainId,
|
|
381
|
+
network: externalWalletNetwork,
|
|
382
|
+
// Balance information
|
|
383
|
+
balance: externalWalletBalance, // BigInt in wei
|
|
384
|
+
formattedBalance, // String formatted as ETH (e.g., "0.123456")
|
|
385
|
+
// Chain switching
|
|
386
|
+
switchChain: switchExternalWalletChain,
|
|
387
|
+
// Connection status
|
|
388
|
+
isConnected: isExternalWalletConnected,
|
|
389
|
+
address: externalWalletAddress,
|
|
390
|
+
// Wallet client for executing transactions
|
|
391
|
+
walletClient,
|
|
392
|
+
};
|
|
393
|
+
}
|
|
394
|
+
//# sourceMappingURL=hooks.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hooks.js","sourceRoot":"","sources":["../../src/hooks.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,EAAE,QAAQ,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AACzD,OAAO,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AAGvD;;GAEG;AACH,MAAM,UAAU,cAAc;IAC5B,MAAM,EAAE,WAAW,EAAE,GAAG,iBAAiB,EAAE,CAAC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OAAO,MAAM,WAAW,CAAC,OAAO,CAAC,CAAC;QACpC,CAAC;KACF,CAAC;IAEF,OAAO;QACL,oBAAoB;QACpB,OAAO,EAAE,qBAAqB;QAC9B,OAAO,EAAE,qBAAqB;QAE9B,sBAAsB;QACtB,OAAO,EAAE,qBAAqB,EAAE,gBAAgB;QAChD,gBAAgB,EAAE,6CAA6C;QAE/D,kBAAkB;QAClB,WAAW,EAAE,yBAAyB;QAEtC,oBAAoB;QACpB,WAAW,EAAE,yBAAyB;QACtC,OAAO,EAAE,qBAAqB;QAE9B,2CAA2C;QAC3C,YAAY;KACb,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* React integration exports for Abstraxn Wallet SDK
|
|
3
|
+
* This file uses .tsx extension and will be compiled separately
|
|
4
|
+
* when used in a React project
|
|
5
|
+
*/
|
|
6
|
+
export { AbstraxnProvider, useAbstraxnWallet } from './AbstraxnProvider';
|
|
7
|
+
export { useIsConnected, useAddress, useUser, useChainId, useIsInitialized, useLoading, useError, useWallet, usePrepareTransaction, useSignTransaction, useSignAndSendTransaction, useExportWallet, useWhoami, useExternalWallet, useExternalWalletBalance, useExternalWalletChain, useExternalWalletInfo, } from './hooks';
|
|
8
|
+
export { ConnectButton } from './ConnectButton';
|
|
9
|
+
export type { ConnectButtonProps, ConnectButtonVariant, ConnectButtonSize } from './ConnectButton';
|
|
10
|
+
export { WalletModal } from './WalletModal';
|
|
11
|
+
export type { WalletModalProps } from './WalletModal';
|
|
12
|
+
export { OnboardingUIComponent as OnboardingUI } from './OnboardingUI';
|
|
13
|
+
export type { AbstraxnProviderConfig, AbstraxnUIConfig, AbstraxnContextValue, } from './types';
|
|
14
|
+
export type { OnboardingUIComponentProps, OnboardingUIComponentRef } from './OnboardingUI';
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* React integration exports for Abstraxn Wallet SDK
|
|
3
|
+
* This file uses .tsx extension and will be compiled separately
|
|
4
|
+
* when used in a React project
|
|
5
|
+
*/
|
|
6
|
+
export { AbstraxnProvider, useAbstraxnWallet } from './AbstraxnProvider';
|
|
7
|
+
export { useIsConnected, useAddress, useUser, useChainId, useIsInitialized, useLoading, useError, useWallet, usePrepareTransaction, useSignTransaction, useSignAndSendTransaction, useExportWallet, useWhoami, useExternalWallet, useExternalWalletBalance, useExternalWalletChain, useExternalWalletInfo, } from './hooks';
|
|
8
|
+
export { ConnectButton } from './ConnectButton';
|
|
9
|
+
export { WalletModal } from './WalletModal';
|
|
10
|
+
export { OnboardingUIComponent as OnboardingUI } from './OnboardingUI';
|
|
11
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +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"}
|
|
@@ -0,0 +1,181 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* React-specific types for Abstraxn Wallet SDK
|
|
3
|
+
*/
|
|
4
|
+
import type { AbstraxnWalletConfig, User, WhoamiResponse } from 'signer-test-sdk-core';
|
|
5
|
+
import type { Theme } from 'signer-test-sdk-core';
|
|
6
|
+
/**
|
|
7
|
+
* UI Configuration for the provider
|
|
8
|
+
*/
|
|
9
|
+
export interface AbstraxnUIConfig {
|
|
10
|
+
/**
|
|
11
|
+
* Theme: 'light' or 'dark'
|
|
12
|
+
* @default 'light'
|
|
13
|
+
*/
|
|
14
|
+
theme?: Theme;
|
|
15
|
+
/**
|
|
16
|
+
* Custom logo URL or HTML string
|
|
17
|
+
*/
|
|
18
|
+
logo?: string;
|
|
19
|
+
/**
|
|
20
|
+
* Onboarding title/heading
|
|
21
|
+
* @default 'Sign in'
|
|
22
|
+
*/
|
|
23
|
+
onboardTitle?: string;
|
|
24
|
+
/**
|
|
25
|
+
* Enable or disable footer
|
|
26
|
+
* @default true
|
|
27
|
+
*/
|
|
28
|
+
showFooter?: boolean;
|
|
29
|
+
/**
|
|
30
|
+
* Custom CSS class name for the modal
|
|
31
|
+
*/
|
|
32
|
+
className?: string;
|
|
33
|
+
/**
|
|
34
|
+
* Custom CSS styles (as string or object)
|
|
35
|
+
*/
|
|
36
|
+
style?: string | Partial<CSSStyleDeclaration>;
|
|
37
|
+
/**
|
|
38
|
+
* Show as modal overlay
|
|
39
|
+
* @default true
|
|
40
|
+
*/
|
|
41
|
+
modal?: boolean;
|
|
42
|
+
/**
|
|
43
|
+
* Close modal when clicking outside
|
|
44
|
+
* @default true
|
|
45
|
+
*/
|
|
46
|
+
closeOnBackdropClick?: boolean;
|
|
47
|
+
/**
|
|
48
|
+
* Show close button
|
|
49
|
+
* @default true
|
|
50
|
+
*/
|
|
51
|
+
showCloseButton?: boolean;
|
|
52
|
+
/**
|
|
53
|
+
* Custom CSS overrides (injected as style tag)
|
|
54
|
+
*/
|
|
55
|
+
customCSS?: string;
|
|
56
|
+
/**
|
|
57
|
+
* Custom labels for UI elements
|
|
58
|
+
*/
|
|
59
|
+
labels?: {
|
|
60
|
+
emailLabel?: string;
|
|
61
|
+
emailPlaceholder?: string;
|
|
62
|
+
otpLabel?: string;
|
|
63
|
+
otpPlaceholder?: string;
|
|
64
|
+
emailButton?: string;
|
|
65
|
+
otpButton?: string;
|
|
66
|
+
googleButton?: string;
|
|
67
|
+
connectButton?: string;
|
|
68
|
+
disconnectButton?: string;
|
|
69
|
+
[key: string]: string | undefined;
|
|
70
|
+
};
|
|
71
|
+
/**
|
|
72
|
+
* Custom colors for theming
|
|
73
|
+
*/
|
|
74
|
+
colors?: {
|
|
75
|
+
primary?: string;
|
|
76
|
+
primaryHover?: string;
|
|
77
|
+
background?: string;
|
|
78
|
+
text?: string;
|
|
79
|
+
border?: string;
|
|
80
|
+
error?: string;
|
|
81
|
+
success?: string;
|
|
82
|
+
};
|
|
83
|
+
/**
|
|
84
|
+
* Authentication methods to show in UI
|
|
85
|
+
* If not provided, shows both email and Google options
|
|
86
|
+
* @default ['otp', 'google']
|
|
87
|
+
*/
|
|
88
|
+
authMethods?: ('otp' | 'google' | 'passkey' | 'twitter' | 'discord')[];
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* External wallet configuration
|
|
92
|
+
*/
|
|
93
|
+
export interface ExternalWalletConfig {
|
|
94
|
+
/**
|
|
95
|
+
* Enable external wallet support (MetaMask, WalletConnect, etc.)
|
|
96
|
+
* @default false
|
|
97
|
+
*/
|
|
98
|
+
enabled?: boolean;
|
|
99
|
+
/**
|
|
100
|
+
* WalletConnect project ID (required for WalletConnect connector)
|
|
101
|
+
*/
|
|
102
|
+
walletConnectProjectId?: string;
|
|
103
|
+
/**
|
|
104
|
+
* Enabled connectors
|
|
105
|
+
* @default ['injected']
|
|
106
|
+
*/
|
|
107
|
+
connectors?: ('injected' | 'metaMask' | 'walletConnect')[];
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* Complete configuration for AbstraxnProvider
|
|
111
|
+
*/
|
|
112
|
+
export interface AbstraxnProviderConfig extends AbstraxnWalletConfig {
|
|
113
|
+
/**
|
|
114
|
+
* UI Configuration
|
|
115
|
+
*/
|
|
116
|
+
ui?: AbstraxnUIConfig;
|
|
117
|
+
/**
|
|
118
|
+
* Auto-initialize IndexedDB on mount
|
|
119
|
+
* @default true
|
|
120
|
+
*/
|
|
121
|
+
autoInit?: boolean;
|
|
122
|
+
/**
|
|
123
|
+
* Show onboarding UI automatically when not authenticated
|
|
124
|
+
* @default false
|
|
125
|
+
*/
|
|
126
|
+
autoShowOnboarding?: boolean;
|
|
127
|
+
/**
|
|
128
|
+
* External wallet configuration
|
|
129
|
+
*/
|
|
130
|
+
externalWallets?: ExternalWalletConfig;
|
|
131
|
+
}
|
|
132
|
+
/**
|
|
133
|
+
* Context value type
|
|
134
|
+
*/
|
|
135
|
+
export interface AbstraxnContextValue {
|
|
136
|
+
wallet: import('signer-test-sdk-core').AbstraxnWallet | null;
|
|
137
|
+
isInitialized: boolean;
|
|
138
|
+
isConnected: boolean;
|
|
139
|
+
address: string | null;
|
|
140
|
+
user: User | null;
|
|
141
|
+
whoami: WhoamiResponse | null;
|
|
142
|
+
chainId: number | null;
|
|
143
|
+
error: Error | null;
|
|
144
|
+
loading: boolean;
|
|
145
|
+
init: () => Promise<void>;
|
|
146
|
+
connect: () => Promise<void>;
|
|
147
|
+
disconnect: () => Promise<void>;
|
|
148
|
+
showOnboarding: () => void;
|
|
149
|
+
hideOnboarding: () => void;
|
|
150
|
+
getAddress: () => Promise<string>;
|
|
151
|
+
getChainId: () => Promise<number>;
|
|
152
|
+
switchChain: (chainId: number) => Promise<void>;
|
|
153
|
+
signMessage: (message: string) => Promise<string>;
|
|
154
|
+
signTransaction: (tx: import('signer-test-sdk-core').TransactionRequest) => Promise<string>;
|
|
155
|
+
sendTransaction: (tx: import('signer-test-sdk-core').TransactionRequest) => Promise<import('signer-test-sdk-core').TransactionResponse>;
|
|
156
|
+
signTransactionViaAPI: (unsignedTransaction: string, fromAddress: string) => Promise<{
|
|
157
|
+
signedTransaction: string;
|
|
158
|
+
}>;
|
|
159
|
+
signAndSendTransaction: (unsignedTransaction: string, fromAddress: string, rpcUrl?: string) => Promise<import('signer-test-sdk-core').TransactionResponse>;
|
|
160
|
+
loginWithOTP: (email: string) => Promise<{
|
|
161
|
+
otpId: string;
|
|
162
|
+
}>;
|
|
163
|
+
verifyOTP: (otpId: string, otpCode: string) => Promise<void>;
|
|
164
|
+
loginWithGoogle: () => Promise<void>;
|
|
165
|
+
handleGoogleCallback: () => Promise<void>;
|
|
166
|
+
refreshWhoami: () => Promise<WhoamiResponse | null>;
|
|
167
|
+
connectExternalWallet?: (connectorId: string) => Promise<void>;
|
|
168
|
+
disconnectExternalWallet?: () => Promise<void>;
|
|
169
|
+
isExternalWalletConnected?: boolean;
|
|
170
|
+
externalWalletAddress?: string | null;
|
|
171
|
+
externalWalletChainId?: number | null;
|
|
172
|
+
externalWalletBalance?: bigint | null;
|
|
173
|
+
externalWalletNetwork?: string | null;
|
|
174
|
+
availableConnectors?: Array<{
|
|
175
|
+
id: string;
|
|
176
|
+
name: string;
|
|
177
|
+
icon?: string;
|
|
178
|
+
}>;
|
|
179
|
+
switchExternalWalletChain?: (chainId: number) => Promise<void>;
|
|
180
|
+
uiConfig?: AbstraxnUIConfig;
|
|
181
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":""}
|