@@ -3,8 +3,7 @@ import { zeroAddress, type Address, type Hash } from "viem";
33import { getContract , getEscrowContract , withContractRecovery } from "@/composables/useContracts" ;
44import { NAME_ESCROW_ADDRESS } from "@/lib/abis/nameEscrow" ;
55import { useContractWrite } from "@/lib/contractWrite" ;
6- import { isRefundableDeposit } from "@/lib/escrowStatus" ;
7- import { isSameEvmAddress } from "@/lib/address" ;
6+ import { isAccountPosition } from "@/lib/escrowStatus" ;
87import { computeDomainTokenId , normalizeDomainName , ZERO_SUBSTRATE_ADDRESS } from "../utils" ;
98
109export type EscrowPosition = {
@@ -84,19 +83,25 @@ export const useEscrowStore = defineStore("useEscrowStore", () => {
8483 // by the escrow contract) still resolves through the caller's own label set;
8584 // the recipient filter drops names transferred away whose position rebound to
8685 // someone else.
86+ //
87+ // Reads run sequentially, mirroring the CLI. A parallel burst overruns the
88+ // chainHead_follow subscription, and every read that then sees "No active
89+ // follow" races to reset the shared client out from under the others, so the
90+ // retries fail too and those positions silently vanish. Pacing the reads keeps
91+ // the subscription alive and a single recovery serves the whole list.
8792 async function listAccountPositions (
8893 recipient : Address ,
8994 domains : string [ ] ,
9095 ) : Promise < EscrowPosition [ ] > {
91- const results = await Promise . all (
92- domains . map ( ( domain ) => getPosition ( domain ) . catch ( ( ) => null ) ) ,
93- ) ;
94- return results . filter (
95- ( position ) : position is EscrowPosition =>
96- position !== null &&
97- isSameEvmAddress ( position . recipient , recipient ) &&
98- isRefundableDeposit ( position ) ,
99- ) ;
96+ const positions : EscrowPosition [ ] = [ ] ;
97+ for ( const domain of domains ) {
98+ const position = await getPosition ( domain ) . catch ( ( error ) => {
99+ console . warn ( `[useEscrowStore] failed to read escrow position for ${ domain } ` , error ) ;
100+ return null ;
101+ } ) ;
102+ if ( isAccountPosition ( position , recipient ) ) positions . push ( position ) ;
103+ }
104+ return positions ;
100105 }
101106
102107 // pendingRefunds returns ids and entries together, so one read covers the page.
0 commit comments