Skip to content

fix(app): skip legacy MedicalAsset accounts in technician jobs fetch #52 - #60

Merged
licette32 merged 1 commit into
mainfrom
fix/bug-52-technician-jobs-fetch
Aug 23, 2026
Merged

licette32 merged 1 commit into
mainfrom
fix/bug-52-technician-jobs-fetch

Conversation

@licette32

@licette32 licette32 commented Aug 23, 2026 •

Copy link
Copy Markdown
Owner

Summary

Cierra el issue #52. El fetch de "Available Jobs" en el dashboard del técnico fallaba silenciosamente por dos causas combinadas: el RPC público de Devnet cerraba conexiones en llamadas pesadas de getProgramAccounts, y una vez resuelto eso, el decode de Anchor crasheaba con RangeError al toparse con 2 cuentas legacy de un layout de programa anterior (58 bytes vs los 70 actuales).

Changes

  • assetDiscovery.ts: fetchAllAssets ahora usa getProgramAccounts crudo con el mismo filtro memcmp que usaba .all(), un guard de tamaño que descarta cuentas legacy, y decode por cuenta individual. fetchHospitalAssets no fue tocado.
  • WalletProvider.tsx: RPC endpoint configurable vía VITE_RPC_URL (Helius), con fallback al público.
  • main.tsx: polyfill de Buffer para bn.js/@solana/web3.js en el navegador.

Testing

  • tsc --noEmit: sin errores.
  • Verificado manualmente: Available Jobs muestra correctamente los 4 activos con Issue Reported, coincidiendo con el estado real del dashboard del hospital. Completar mantenimiento (Complete & Get Paid) confirmado funcionando de punta a punta — Jobs Completed y Total Earned se actualizan correctamente tras la transacción.

Notes

  • Detectado en el proceso: un mensaje transitorio de "Transaction not found or not confirmed yet" que aparece brevemente tras completar un mantenimiento, aunque la transacción sí se confirma. Trackeado por separado (issue de polling/UI, no bloqueante).

Closes #52

…52)

fetchAllAssets used program.account.medicalAsset.all([]), whose
internal decode throws RangeError on accounts minted by an older
program layout (58 bytes, predating maintenance_reward/failure_count
vs the current 70-byte struct) - killing the entire fetch even when
valid accounts exist.

Replaced with a raw getProgramAccounts call using the same memcmp
discriminator filter, a size guard to skip legacy accounts, and
per-account decoding via program.coder.accounts.decode.
fetchHospitalAssets is untouched - it already scopes by hospital and
never hit this path.
@licette32 licette32 added this to the v1.1 — Demo Day milestone Aug 23, 2026
@licette32 licette32 self-assigned this Aug 23, 2026
@vercel

vercel Bot commented Aug 23, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
medovant-protocol Ready Ready Preview Aug 23, 2026 3:05pm

@licette32
licette32 merged commit 39afbef into main Aug 23, 2026
4 checks passed

This branch was successfully deployed

1 active deployment
Preview — 40edc41e Deployed Aug 23, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] "Failed to load assets" error in Technician Dashboard's Available Jobs table

1 participant