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,7 +20,10 @@ export async function fetchEscrowsForWallet(
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
.getProgramAccounts(DESCRO_PROGRAM_ADDRESS, {
filters: [
@@ -39,12 +42,22 @@ export async function fetchEscrowsForWallet(
encoding: "base64",
})
.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 results: EscrowAccountWithPda[] = [];
for (const item of [...asSeller, ...asBuyer]) {
for (const item of [...asSeller, ...asBuyer, ...asResolver]) {
const pda = item.pubkey;
if (seen.has(pda)) continue;
seen.add(pda);