component handles
+ // the logic of bundling these for Smart Wallets or serializing them for EOAs.
+ const getCalls = useCallback(() => {
+ const amountBigInt = parseUnits(amount, 6); // USDC = 6 decimals
+
+ return [
+ {
+ to: USDC_ADDRESS,
+ abi: erc20Abi,
+ functionName: 'approve',
+ args: [VAULT_ADDRESS, amountBigInt],
+ },
+ {
+ to: VAULT_ADDRESS,
+ abi: VAULT_ABI,
+ functionName: 'deposit',
+ args: [amountBigInt],
+ }
+ ];
+ }, [amount]);
+
+ // 2. Handle Finality
+ // This callback fires only when the transaction is confirmed on-chain.
+ const handleSuccess = useCallback(async (response: any) => {
+ // Extract the transaction hash from the receipt
+ const txHash = response.transactionReceipts?.[0]?.transactionHash;
+
+ if (txHash) {
+ // Trigger backend re-indexing immediately
+ await fetch('/api/indexer/sync-user', {
+ method: 'POST',
+ headers: { 'Content-Type': 'application/json' },
+ body: JSON.stringify({
+ userAddress: response.transactionReceipts[0].from,
+ txHash: txHash
+ })
+ });
+ }
+ }, []);
+
+ return (
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ );
+}
+
+```
+
+---