Skip to content

[nil.js] Simplified Transaction Status Reporting in niljs #620

Open
@gitshreevatsa

Description

@gitshreevatsa

Overview

Enhance niljs transaction methods to return both transaction hash and detailed status information without requiring developers to manually loop through nested JSON structures.

Background

Currently, when using methods like smartAccount.sendTransaction or smartAccount.deployContract, developers only receive a transaction hash. To determine transaction status and error information, they must call client.getTransactionReceipt, then manually loop through complex nested JSON structures to check for failure flags and extract error messages.

Feature Requirements

Improve transaction-related methods in niljs to:

  1. Return transaction hash along with parsed status information in a single response
  2. Automatically extract and surface error messages when transactions fail
  3. Eliminate the need for manual JSON traversal to determine transaction outcomes

Technical Implementation Steps

  1. Create a transaction result parser:

    • Implement logic to traverse transaction receipt JSON
    • Extract status flags and error messages from nested structures
    • Transform complex receipt data into developer-friendly format
  2. Enhance transaction method return objects:

    • Return both transaction hash and parsed status information
    • Include formatted error messages when transactions fail
    • Provide boolean success indicator for quick status checks
  3. Update interfaces:

    • Modify return types for all transaction methods
    • Ensure backward compatibility with existing code
    • Document new return object structure
  4. Implement error categorization:

    • Standardize error message formats
    • Group common error types for easier handling
    • Provide context-specific error information

Technical References

Acceptance Criteria

  • All transaction methods return an object containing:
    • Transaction hash
    • Success/failure status
    • Detailed error message when applicable
  • Developers no longer need to manually traverse nested JSON
  • Failed transactions have clear, actionable error messages
  • Existing code expecting only transaction hash continues to work
  • Changes follow consistent patterns across the library

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions