This commit is contained in:
thesn10
2026-05-23 23:21:55 +02:00
parent d7d57ca7a4
commit 032416fffd
3 changed files with 22 additions and 3 deletions

View File

@@ -20,6 +20,12 @@ export default function PlaygroundPage() {
const [mounted, setMounted] = useState(false) const [mounted, setMounted] = useState(false)
useEffect(() => { setMounted(true) }, []) useEffect(() => { setMounted(true) }, [])
useEffect(() => {
if (selected && !escrows.some((e) => e.pda === selected.pda)) {
setSelected(null)
}
}, [escrows, selected])
return ( return (
<YStack flex={1} minHeight="100vh" backgroundColor="$background"> <YStack flex={1} minHeight="100vh" backgroundColor="$background">
{/* Header */} {/* Header */}

View File

@@ -172,7 +172,7 @@ export function ResolverPanel() {
<Text fontWeight="600">{account.name}</Text> <Text fontWeight="600">{account.name}</Text>
<Text fontSize={12} color="$color10">{resolverTypeLabel(account.resolverType)}</Text> <Text fontSize={12} color="$color10">{resolverTypeLabel(account.resolverType)}</Text>
</XStack> </XStack>
{account.description && ( {!!account.description && (
<Text fontSize={12} color="$color10">{account.description}</Text> <Text fontSize={12} color="$color10">{account.description}</Text>
)} )}
<XStack gap="$4"> <XStack gap="$4">

View File

@@ -20,7 +20,10 @@ export async function fetchEscrowsForWallet(
const walletBytes = walletAddress as never; const walletBytes = walletAddress as never;
const [asSeller, asBuyer] = await Promise.all([ // Option<Pubkey> for disputeResolver: 1-byte discriminant (1=Some) at offset 80, pubkey at offset 81
const someVariantBase64 = btoa(String.fromCharCode(1)) as never;
const [asSeller, asBuyer, asResolver] = await Promise.all([
rpc rpc
.getProgramAccounts(DESCRO_PROGRAM_ADDRESS, { .getProgramAccounts(DESCRO_PROGRAM_ADDRESS, {
filters: [ filters: [
@@ -39,12 +42,22 @@ export async function fetchEscrowsForWallet(
encoding: "base64", encoding: "base64",
}) })
.send(), .send(),
rpc
.getProgramAccounts(DESCRO_PROGRAM_ADDRESS, {
filters: [
{ memcmp: { offset: 0n, bytes: discriminatorBase64, encoding: "base64" } },
{ memcmp: { offset: 80n, bytes: someVariantBase64, encoding: "base64" } },
{ memcmp: { offset: 81n, bytes: walletBytes, encoding: "base58" } },
],
encoding: "base64",
})
.send(),
]); ]);
const seen = new Set<string>(); const seen = new Set<string>();
const results: EscrowAccountWithPda[] = []; const results: EscrowAccountWithPda[] = [];
for (const item of [...asSeller, ...asBuyer]) { for (const item of [...asSeller, ...asBuyer, ...asResolver]) {
const pda = item.pubkey; const pda = item.pubkey;
if (seen.has(pda)) continue; if (seen.has(pda)) continue;
seen.add(pda); seen.add(pda);