@abstraxn/signer-react 1.0.16 → 2.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/CHANGELOG.md CHANGED
@@ -5,6 +5,33 @@ All notable changes to this project will be documented in this file.
5
5
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6
6
  and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
7
 
8
+ ## [2.0.1] - 2026-03-03
9
+
10
+ ### Fixed
11
+
12
+ - **Abstraxn wallet balance polling** – Removed the 10-second interval that refetched the connected Abstraxn wallet’s native balance from the chain RPC. Balance is still fetched once when the user connects (email, Google, passkey, Twitter, Discord) or when address/chain changes, but no longer triggers an RPC call every 10 seconds while the session is active.
13
+
14
+ ## [2.0.0] - 2026-03-02
15
+
16
+ ### Added
17
+
18
+ - **First-class Solana support (embedded wallets)** – New Turnkey-backed Solana hooks to prepare, sign, and send Solana transactions using the same embedded wallet that users get from email/social/passkey login:
19
+ - `useSolanaConnection(rpcUrl, commitment?)` – creates a `Connection` for Solana RPC.
20
+ - `useSolanaPublicKey()` – reads `whoami.solanaAddress` and exposes `{ solanaAddress, isConnected }`.
21
+ - `usePrepareSolanaTxn(connection)` – returns `prepareSolanaTransfer({ fromPubkey, toPubkey, amountInSol })` for native SOL transfers.
22
+ - `useSignSolanaTxn(connection)` / `useSignAndSendSolanaTxn(connection)` – sign (and optionally send) Solana transactions via Turnkey using `TRANSACTION_TYPE_SOLANA`.
23
+ - `useWaitForSolanaConfirmation(connection)` – waits for Solana transaction confirmation.
24
+ - **Solana program (contract) transactions** – High-level APIs for program calls without exposing `@solana/web3.js` to app code:
25
+ - `SolanaAccountMetaInput` / `SolanaInstructionDataInput` types to describe accounts and encoded instruction data.
26
+ - `usePrepareSolanaProgramTxn(connection)` – builds a `Transaction` from `{ feePayer, programId, accounts, data }`.
27
+ - `useSolanaProgramTransaction(connection)` – `sendProgramTransaction(...)` helper that prepares, signs, and broadcasts a Solana program transaction in one call and returns `{ signature, unsignedTransaction, signedTransaction }` (hex).
28
+ - **Docs** – New `SOLANA.md` with end-to-end examples for native SOL transfers and program calls, and README updates pointing to the new Solana hooks.
29
+
30
+ ### Changed
31
+
32
+ - **WalletModal send flow** – `useSendTransaction` inside the Wallet modal now supports Solana chains for native transfers by delegating to the new Solana hooks instead of throwing `"Solana transactions are not yet supported"`. EVM behavior is unchanged.
33
+ - **Turnkey integration (internal)** – Solana unsigned transactions are now serialized and sent to Turnkey as hex, and the signed hex is converted back to bytes for `sendRawTransaction`. This matches Turnkey’s `TRANSACTION_TYPE_SOLANA` expectations and prevents decode errors.
34
+
8
35
  ## [1.0.16] - 2026-02-23
9
36
 
10
37
  ### Fixed
package/README.md CHANGED
@@ -98,11 +98,107 @@ function HookConnectButton() {
98
98
 
99
99
  - `useAbstraxnWallet()` - Main wallet hook
100
100
  - `useIsConnected()` - Check connection status
101
- - `useAddress()` - Get wallet address
102
- - `useWhoami()` - Get user information
103
- - `useExternalWalletInfo()` - External wallet information
104
- - `usePrepareTransaction()` - Prepare and sign transactions
105
- - `useExportWallet()` - Export wallet
101
+ - `useAddress()` - Get wallet address (EVM)
102
+ - `useWhoami()` - Get user information (includes `solanaAddress` when available)
103
+ - `useExternalWalletInfo()` - External wallet information (EVM)
104
+ - `useExportWallet()` - Export wallet (EVM or Solana, based on current chain)
105
+ - `usePublicClient()` / `usePrepareRawTxn()` / `useSignTxn()` / `useSignAndSendTxn()` / `useWaitForTxnReceipt()` - EVM transaction flow (prepare → sign → send → confirm)
106
+ - `useSolanaConnection()` / `useSolanaPublicKey()` / `usePrepareSolanaTxn()` / `useSignSolanaTxn()` / `useSignAndSendSolanaTxn()` / `useWaitForSolanaConfirmation()` - Solana transaction flow (prepare → sign → send → confirm)
107
+
108
+ ### Example: EVM → Solana flow after social/email login
109
+
110
+ ```tsx
111
+ import {
112
+ useAbstraxnWallet,
113
+ usePublicClient,
114
+ usePrepareRawTxn,
115
+ useEstimateGas,
116
+ useGetGasPrice,
117
+ useSignAndSendTxn,
118
+ useWaitForTxnReceipt,
119
+ useSolanaConnection,
120
+ useSolanaPublicKey,
121
+ usePrepareSolanaTxn,
122
+ useSignAndSendSolanaTxn,
123
+ useWaitForSolanaConfirmation,
124
+ } from '@abstraxn/signer-react';
125
+ import { polygonAmoy } from 'viem/chains';
126
+
127
+ function CrossChainExample() {
128
+ const { isConnected } = useAbstraxnWallet();
129
+
130
+ // EVM clients & hooks
131
+ const { publicClient } = usePublicClient(
132
+ polygonAmoy,
133
+ 'https://rpc-amoy.polygon.technology'
134
+ );
135
+ const { prepareRawTxn } = usePrepareRawTxn(publicClient);
136
+ const { estimateGas } = useEstimateGas(publicClient);
137
+ const { getGasPrice } = useGetGasPrice(publicClient);
138
+ const { signAndSendTxn } = useSignAndSendTxn(publicClient);
139
+ const { waitForTxnReceipt } = useWaitForTxnReceipt(publicClient);
140
+
141
+ // Solana clients & hooks
142
+ const { connection } = useSolanaConnection('https://api.devnet.solana.com');
143
+ const { solanaAddress } = useSolanaPublicKey();
144
+ const { prepareSolanaTransfer } = usePrepareSolanaTxn(connection);
145
+ const { signAndSendSolanaTxn } = useSignAndSendSolanaTxn(connection);
146
+ const { waitForSolanaConfirmation } = useWaitForSolanaConfirmation(connection);
147
+
148
+ const handleCrossChain = async () => {
149
+ if (!isConnected) throw new Error('Please login first');
150
+
151
+ // 1) EVM tx (e.g. on Polygon Amoy)
152
+ const from = '0x...'; // current EVM address
153
+ const rawTx = await prepareRawTxn({
154
+ from,
155
+ to: '0x...',
156
+ value: '0.001',
157
+ });
158
+ const { gasLimit } = await estimateGas({
159
+ account: from,
160
+ to: rawTx.to,
161
+ data: rawTx.data,
162
+ value: rawTx.value,
163
+ });
164
+ const fees = await getGasPrice();
165
+
166
+ const evmResult = await signAndSendTxn({
167
+ from,
168
+ ...rawTx,
169
+ gas: {
170
+ gasLimit,
171
+ maxFeePerGas: fees.maxFeePerGas!,
172
+ maxPriorityFeePerGas: fees.maxPriorityFeePerGas!,
173
+ },
174
+ });
175
+
176
+ await waitForTxnReceipt({ hash: evmResult.hash, confirmations: 1 });
177
+
178
+ // 2) After EVM confirmation, send SOL
179
+ if (!solanaAddress) throw new Error('Solana wallet not provisioned');
180
+
181
+ const { transaction } = await prepareSolanaTransfer({
182
+ fromPubkey: solanaAddress,
183
+ toPubkey: 'TargetSolanaAddressHere',
184
+ amountInSol: 0.01,
185
+ });
186
+
187
+ const solanaResult = await signAndSendSolanaTxn({
188
+ transaction,
189
+ fromPubkey: solanaAddress,
190
+ });
191
+
192
+ await waitForSolanaConfirmation({ signature: solanaResult.signature });
193
+ };
194
+
195
+ return (
196
+ <button onClick={handleCrossChain}>
197
+ Run EVM → Solana Flow
198
+ </button>
199
+ );
200
+ }
201
+ ```
106
202
 
107
203
  ## 🔗 Related Packages
108
204
 
@@ -1725,6 +1725,28 @@ export function AbstraxnProviderInner({ config, children, base, wagmi, }) {
1725
1725
  setLoading(false);
1726
1726
  }
1727
1727
  }, []);
1728
+ // Sign Solana transaction via API (returns signed transaction)
1729
+ const signSolanaTransactionViaAPI = useCallback(async (unsignedTransaction, fromAddress) => {
1730
+ if (!walletRef.current)
1731
+ throw new Error("Wallet not initialized");
1732
+ setLoading(true);
1733
+ setError(null);
1734
+ try {
1735
+ const walletAny = walletRef.current;
1736
+ if (typeof walletAny.signSolanaTransactionViaAPI !== "function") {
1737
+ throw new Error("Solana transaction signing is not supported by this wallet");
1738
+ }
1739
+ return await walletAny.signSolanaTransactionViaAPI(unsignedTransaction, fromAddress);
1740
+ }
1741
+ catch (err) {
1742
+ const error = err instanceof Error ? err : new Error("Failed to sign Solana transaction");
1743
+ setError(error);
1744
+ throw error;
1745
+ }
1746
+ finally {
1747
+ setLoading(false);
1748
+ }
1749
+ }, []);
1728
1750
  // Sign typed data / raw payload via API (same flow as signTransactionViaAPI, payload: from, unsignedTransaction, encoding, hashFunction)
1729
1751
  const signTypedTxViaAPI = useCallback(async (fromAddress, unsignedTransaction, encoding, hashFunction) => {
1730
1752
  if (!walletRef.current)
@@ -2687,9 +2709,6 @@ export function AbstraxnProviderInner({ config, children, base, wagmi, }) {
2687
2709
  }
2688
2710
  };
2689
2711
  fetchBalance();
2690
- // Refetch balance every 10 seconds
2691
- const interval = setInterval(fetchBalance, 10000);
2692
- return () => clearInterval(interval);
2693
2712
  }, [address, currentChainId, isExternalWalletConnected]);
2694
2713
  // Compute available chains from config - supports both legacy and new format
2695
2714
  const availableChains = useMemo(() => {
@@ -2855,6 +2874,7 @@ export function AbstraxnProviderInner({ config, children, base, wagmi, }) {
2855
2874
  signTransaction,
2856
2875
  sendTransaction,
2857
2876
  signTransactionViaAPI,
2877
+ signSolanaTransactionViaAPI,
2858
2878
  signTypedTxViaAPI,
2859
2879
  signAndSendTransaction,
2860
2880
  loginWithOTP,