diff --git a/src/components/AgentRegister.tsx b/src/components/AgentRegister.tsx index eacaadba..835773c3 100644 --- a/src/components/AgentRegister.tsx +++ b/src/components/AgentRegister.tsx @@ -18,7 +18,8 @@ const LLM_MODELS = [ "Cursor Composer", "xAI Grok", "Moonshot Kimi", "DeepSeek", "Qwen", "Others", ] as const; -type WizardStep = 1 | 2 | "3a" | "3b" | "3c" | "done"; +type WizardStep = 1 | 2 | "done"; +type BindStep = "enter" | "sign" | "submit" | "bound" | null; const EIP712_DOMAIN = { name: "ERC8004IdentityRegistry", @@ -56,6 +57,7 @@ export function AgentRegister() { const [signing, setSigning] = useState(false); const [binding, setBinding] = useState(false); const [bindTxHash, setBindTxHash] = useState(); + const [bindStep, setBindStep] = useState(null); const [error, setError] = useState(null); const agentURI = useMemo(() => { @@ -122,7 +124,7 @@ export function AgentRegister() { } catch { setError("On-chain OK, but cache failed — will sync on next visit"); } - setStep("3a"); + setStep("done"); } catch (err) { setError(err instanceof Error ? err.message : "Registration failed"); } finally { @@ -144,7 +146,7 @@ export function AgentRegister() { }); setAgentSignature(signature); setSignatureDeadline(deadline); - setStep("3c"); + setBindStep("submit"); } catch (err) { setError(err instanceof Error ? err.message : "Agent wallet signing failed"); } finally { @@ -174,7 +176,7 @@ export function AgentRegister() { fields: { agent_wallet: agentWallet.toLowerCase() }, }), }).catch(() => {}); - setStep("done"); + setBindStep("bound"); } catch (err) { setError(err instanceof Error ? err.message : "Wallet binding failed"); } finally { @@ -187,13 +189,13 @@ export function AgentRegister() { const isOwnerWalletConnected = ownerAddress && address?.toLowerCase() === ownerAddress.toLowerCase(); - const stepNum = typeof step === "number" ? step : step === "done" ? 4 : 3; + const stepNum = typeof step === "number" ? step : 3; return (
{/* Step indicator */}
- {([1, 2, 3] as const).map((s) => ( + {([1, 2] as const).map((s) => (
{s < stepNum ? "\u2713" : s}
- {s < 3 &&
} + {s < 2 &&
}
))} {step === 1 && "Agent Profile"} {step === 2 && "On-chain Registration"} - {(step === "3a" || step === "3b" || step === "3c") && "Bind Wallet"} {step === "done" && "Complete"}
@@ -280,101 +281,106 @@ export function AgentRegister() {
)} - {/* Step 3a: Enter agent wallet */} - {step === "3a" && ( -
- {agentId !== undefined && ( -
-

Agent registered successfully

-

Agent ID: {agentId.toString()}

-
- )} -

- Bind a separate wallet to your agent. The agent wallet must sign an EIP-712 message to prove consent. -

-
- - setAgentWallet(e.target.value)} placeholder="0x..." - className="border-border bg-surface text-foreground placeholder:text-muted w-full rounded border px-3 py-2 text-sm font-mono focus:border-accent focus:outline-none" /> -
-
- - -
-
- )} - - {/* Step 3b: Sign with agent wallet */} - {step === "3b" && ( -
-
-

Switch to the agent wallet

-

{agentWallet}

-
-
-
- - {isAgentWalletConnected ? Agent wallet connected. Ready to sign. - : <>Currently: {address?.slice(0, 6)}...{address?.slice(-4)}} - -
-
- - -
-
- )} - - {/* Step 3c: Submit as owner */} - {step === "3c" && ( -
-
-

Agent wallet signature obtained

-
-
-

Switch back to the owner wallet

-

{ownerAddress}

-
-
-
- - {isOwnerWalletConnected ? Owner wallet connected. Ready to submit. - : <>Currently: {address?.slice(0, 6)}...{address?.slice(-4)}} - -
- {bindTxHash && ( - - )} -
- - -
-
- )} - {/* Done */} {step === "done" && ( -
-
+
+

Agent registration complete

{agentId !== undefined &&

Agent ID: {agentId.toString()}

}
+ {agentId !== undefined && ( +
+ { if (!bindStep) setBindStep("enter"); }}> + Optional — Want to use a different wallet for your agent? + +
+

+ By default, your connected wallet is used as the agent wallet. You can bind a separate wallet for CLI/bot usage. +

+ + {/* Enter address */} + {bindStep === "enter" && ( +
+
+ + setAgentWallet(e.target.value)} placeholder="0x..." + className="border-border bg-surface text-foreground placeholder:text-muted w-full rounded border px-3 py-2 text-sm font-mono focus:border-accent focus:outline-none" /> +
+ +
+ )} + + {/* Sign with agent wallet */} + {bindStep === "sign" && ( +
+
+

Switch to the agent wallet

+

{agentWallet}

+
+
+
+ + {isAgentWalletConnected ? Agent wallet connected. Ready to sign. + : <>Currently: {address?.slice(0, 6)}...{address?.slice(-4)}} + +
+
+ + +
+
+ )} + + {/* Submit binding as owner */} + {bindStep === "submit" && ( +
+
+

Agent wallet signature obtained

+
+
+

Switch back to the owner wallet

+

{ownerAddress}

+
+
+
+ + {isOwnerWalletConnected ? Owner wallet connected. Ready to submit. + : <>Currently: {address?.slice(0, 6)}...{address?.slice(-4)}} + +
+ {bindTxHash && ( + + )} + +
+ )} + + {/* Binding complete */} + {bindStep === "bound" && ( +
+

Agent wallet bound successfully

+

{agentWallet}

+
+ )} +
+
+ )}
)}