Skip to content

Task 04: Hardcoded Error in Frontend #300

Description

@grantfox-oss

Soroban contracts utilize numeric error codes that map to specific business logic failures. In Grat, the canonical mappings for these errors, along with their detailed descriptions, causes, and recommended fixes, are stored in the core Rust library via TOML data files. However, the React frontend (ContractErrorView.tsx) completely bypasses this system, instead relying on a hardcoded, static dictionary called standardContractErrors physically written into the TypeScript source code. This architectural flaw creates a split brain scenario. When the core team updates the TOML taxonomy with new error codes, deprecates old ones, or improves the troubleshooting descriptions, the web interface remains silently outdated. Developers using the web UI will see incorrect or missing diagnostic advice, leading to extreme confusion during debugging sessions.

Issues/what to fix

The hardcoded standardContractErrors dictionary must be completely eradicated from ContractErrorView.tsx. To resolve this, a new REST endpoint (e.g., /api/taxonomy/errors) should be created on the Fastify server that serves the parsed TOML data directly from the Rust core. The React component must be updated to use an asynchronous hook to fetch this taxonomy dynamically when the application mounts. If dynamic fetching is not desired, an alternative is to build a script that compiles the TOML files into a shared JSON artifact during the monorepo's build process, allowing the frontend to import the generated JSON directly.

Files location

apps/web/src/components/decode/ContractErrorView.tsx, crates/core/src/taxonomy/data/contract.toml

Expected result

The frontend will become entirely data driven. When an error occurs, the UI will dynamically pull the exact, up to date descriptions directly from the core taxonomy, guaranteeing that developers always see the most accurate, synchronized diagnostic advice.

Contributor telegram group

https://t.me/+sII7WPhll2liMGNk

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions