Skip to content

Commit c2ec511

Browse files
sktbrdclaude
andauthored
fix(stake): lootbox e posições leem o EOA (useUserAddress), não o Smart Account (#234)
Com carteira externa + account-abstraction, thirdweb's useActiveAccount() retorna o endereço do Smart Account wrap — mas os stakes/rewards vivem no EOA do usuário (por isso o app usa view-mode "eoa" por padrão). A MorLootbox e o StakePositions liam a posição a partir do SA (vazio), então hasAction ficava false e a lootbox nunca aparecia / o painel mostrava "sem posições". Passa os dois a ler de useUserAddress().address (o endereço efetivo, EOA pra carteiras externas). Writes seguem assinando pela active account dentro dos hooks morpheus/distribute — só a LEITURA muda. Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
1 parent c0c135a commit c2ec511

2 files changed

Lines changed: 11 additions & 4 deletions

File tree

src/components/stake/MorLootbox.tsx

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,12 @@
1111

1212
import { useCallback, useEffect, useState } from "react";
1313
import { useTranslations } from "next-intl";
14-
import { useActiveAccount } from "thirdweb/react";
1514
import { AnimatePresence, motion } from "framer-motion";
1615
import { Gift, Sparkles, X } from "lucide-react";
1716
import { toast } from "sonner";
1817
import { type Address } from "viem";
1918
import { Button } from "@/components/ui/button";
19+
import { useUserAddress } from "@/hooks/use-user-address";
2020
import { useMorpheusPosition } from "@/hooks/use-morpheus-position";
2121
import { useMorpheusStake } from "@/hooks/use-morpheus-stake";
2222
import { useMorDistribute } from "@/hooks/use-mor-distribute";
@@ -30,7 +30,12 @@ const fmt = (n: number) => n.toLocaleString("en-US", { maximumFractionDigits: 4
3030

3131
export function MorLootbox() {
3232
const t = useTranslations("stake");
33-
const you = useActiveAccount()?.address;
33+
// Read off the EFFECTIVE user address (EOA for external wallets), not the raw
34+
// active account — with account-abstraction thirdweb's active account is the
35+
// Smart Account wrap, but stakes/claims live on the user's EOA. Keying reads
36+
// off the SA made the box find no position and never appear. Writes still sign
37+
// through the active account inside the morpheus/distribute hooks.
38+
const { address: you } = useUserAddress();
3439
const [nonce, setNonce] = useState(0);
3540
const position = useMorpheusPosition(you, nonce);
3641
const morpheus = useMorpheusStake();

src/components/stake/StakePositions.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77

88
import { useState } from "react";
99
import { useTranslations } from "next-intl";
10-
import { useActiveAccount } from "thirdweb/react";
1110
import { cn } from "@/lib/utils";
11+
import { useUserAddress } from "@/hooks/use-user-address";
1212
import { Card, CardHeader, CardTitle, CardDescription, CardContent } from "@/components/ui/card";
1313
import { useMorpheusPosition, type MorpheusPoolPosition } from "@/hooks/use-morpheus-position";
1414

@@ -87,7 +87,9 @@ function PositionRow({ p, now, t }: { p: MorpheusPoolPosition; now: number; t: T
8787

8888
export function StakePositions() {
8989
const t = useTranslations("stake.positions");
90-
const you = useActiveAccount()?.address;
90+
// Effective user address (EOA for external wallets) — reads must key off the
91+
// address the stake actually lives on, not the Smart Account wrap.
92+
const { address: you } = useUserAddress();
9193
const pos = useMorpheusPosition(you);
9294
// Lazy initializer keeps render pure — the 7-day / power locks don't need a
9395
// live tick; a refresh re-reads the clock.

0 commit comments

Comments
 (0)