Skip to content

Commit feda15e

Browse files
authored
feat: AA demo app with paymaster and token transfers support (#3609)
1 parent 6833581 commit feda15e

21 files changed

+3730
-2531
lines changed

tee-worker/omni-executor/aa-contracts/aa-demo-app/README.md

Lines changed: 233 additions & 45 deletions
Large diffs are not rendered by default.

tee-worker/omni-executor/aa-contracts/aa-demo-app/src/app/page.tsx

Lines changed: 11 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@ import { useAccount, usePublicClient } from "wagmi";
55
import { WalletConnect } from "@/components/WalletConnect";
66
import { AccountsDashboard } from "@/components/AccountsDashboard";
77
import { FundingGuide } from "@/components/FundingGuide";
8-
import { ERC20FundingGuide } from "@/components/ERC20FundingGuide";
98
import { CreateOmniAccount } from "@/components/CreateOmniAccount";
109
import { AuthorizedSigners } from "@/components/AuthorizedSigners";
1110
import { AuthorizeTEEWorker } from "@/components/AuthorizeTEEWorker";
11+
import { TEETokenTransfer } from "@/components/TEETokenTransfer";
1212
import { ClientOnly } from "@/components/ClientOnly";
1313
import { ChevronRight, Check } from "lucide-react";
1414

@@ -22,20 +22,9 @@ function HomeContent() {
2222
const [hasContract, setHasContract] = useState(false);
2323
const [authorizedSigners, setAuthorizedSigners] = useState<string[]>([]);
2424
const [isLoadingSigners, setIsLoadingSigners] = useState(false);
25-
const [hasERC20Tokens, setHasERC20Tokens] = useState(false);
2625
const [teeWorkerAddress, setTeeWorkerAddress] = useState<string | null>(null);
2726
const [isTeeWorkerAuthorized, setIsTeeWorkerAuthorized] = useState(false);
2827

29-
// Memoized callback for balance updates
30-
const handleBalancesUpdate = useCallback((balances: any[]) => {
31-
// Check if any ERC20 tokens are present
32-
const hasTokens = balances.some(
33-
(tb) => tb.symbol !== "ETH" && tb.balance > BigInt(0)
34-
);
35-
if (hasTokens) {
36-
setHasERC20Tokens(true);
37-
}
38-
}, []);
3928

4029
// Debug logging
4130
useEffect(() => {
@@ -229,12 +218,10 @@ function HomeContent() {
229218
setCurrentStep(3);
230219
} else if (!isTeeWorkerAuthorized) {
231220
setCurrentStep(4);
232-
} else if (!hasERC20Tokens) {
233-
setCurrentStep(5);
234221
} else {
235-
setCurrentStep(6);
222+
setCurrentStep(5);
236223
}
237-
}, [evmAddress, omniAccountAddress, isFunded, isAuthorized, authorizedSigners, isTeeWorkerAuthorized, hasERC20Tokens]);
224+
}, [evmAddress, omniAccountAddress, isFunded, isAuthorized, authorizedSigners, isTeeWorkerAuthorized]);
238225

239226
const steps = [
240227
{
@@ -263,14 +250,8 @@ function HomeContent() {
263250
},
264251
{
265252
id: 5,
266-
title: "Transfer ERC20 Tokens",
267-
description: "Transfer test tokens to your Omni Account",
268-
completed: hasERC20Tokens,
269-
},
270-
{
271-
id: 6,
272-
title: "Ready to Swap",
273-
description: "Send swap requests to the worker",
253+
title: "Send Token Transfer",
254+
description: "Transfer tokens through the TEE worker",
274255
completed: false,
275256
},
276257
];
@@ -394,7 +375,6 @@ function HomeContent() {
394375
onAddressCalculated={setOmniAccountAddress}
395376
onOmniAccountCalculated={setOmniAccountHash}
396377
ethBalance={ethBalance}
397-
onBalancesUpdate={handleBalancesUpdate}
398378
isAccountCreated={isAuthorized}
399379
/>
400380
</div>
@@ -479,34 +459,20 @@ function HomeContent() {
479459
{currentStep >= 5 && currentStep <= 5 && (
480460
<div>
481461
<h2 className="text-xl font-semibold mb-4">
482-
Step 5: Transfer ERC20 Tokens
462+
Step 5: Send Token Transfer
483463
</h2>
484464
<p className="text-gray-600 mb-6">
485-
Mint and transfer test USDC or USDT to your Omni Account for token swaps.
465+
Transfer USDC or USDT through the TEE worker using UserOperations.
486466
</p>
487-
<ERC20FundingGuide
467+
<TEETokenTransfer
488468
omniAccountAddress={omniAccountAddress}
489-
hasERC20Tokens={hasERC20Tokens}
490-
onTokensAdded={() => {
491-
console.log("ERC20 tokens added");
492-
setHasERC20Tokens(true);
493-
}}
469+
omniAccountHash={omniAccountHash}
470+
isDeployed={hasContract}
471+
teeWorkerAddress={teeWorkerAddress}
494472
/>
495473
</div>
496474
)}
497475

498-
{currentStep >= 6 && (
499-
<div>
500-
<h2 className="text-xl font-semibold mb-4">
501-
Step 6: Start Swapping
502-
</h2>
503-
<p className="text-gray-600 mb-6">
504-
Your Omni Account is ready! Send swap requests to the TEE
505-
worker service.
506-
</p>
507-
{/* TODO */}
508-
</div>
509-
)}
510476

511477
{/* Always show completed steps in collapsed form */}
512478
<div className="space-y-4">
@@ -583,23 +549,6 @@ function HomeContent() {
583549
</div>
584550
)}
585551

586-
{hasERC20Tokens && (
587-
<div className="bg-white rounded-lg shadow p-4">
588-
<div className="flex items-center justify-between">
589-
<div className="flex items-center space-x-3">
590-
<div className="w-6 h-6 bg-green-500 rounded-full flex items-center justify-center">
591-
<Check className="w-4 h-4 text-white" />
592-
</div>
593-
<span className="font-medium text-green-700">
594-
ERC20 Tokens Added
595-
</span>
596-
</div>
597-
<span className="text-sm text-gray-500">
598-
Ready for swaps
599-
</span>
600-
</div>
601-
</div>
602-
)}
603552
</div>
604553
</div>
605554
</div>

0 commit comments

Comments
 (0)