Skip to content

feat: Call lifecycle overhaul#60

Open
Alanwiz00 wants to merge 6 commits into
ShippedLabs:mainfrom
Alanwiz00:call-lifecycle-overhaul
Open

feat: Call lifecycle overhaul#60
Alanwiz00 wants to merge 6 commits into
ShippedLabs:mainfrom
Alanwiz00:call-lifecycle-overhaul

Conversation

@Alanwiz00

Copy link
Copy Markdown

Closes #59

Summary

This PR improves the contract invocation flow by addressing three related areas: read-only function detection, resource fee estimation, and transaction submission feedback.

Read-only function detection

  • Detects whether a function is read-only by probing its simulation footprint during contract load.
  • Displays read-only/write badges in the function list without requiring an initial manual simulation.
  • Falls back to an unknown state for functions that cannot be classified up front (for example, those requiring complex argument types), allowing both actions until a real simulation is performed.

Resource fee estimation

  • Extends contract simulation to expose the estimated resource fee.
  • Displays the estimated fee in both stroops and XLM before a transaction is submitted.
  • Clears the estimate whenever the selected function or its inputs change, preventing stale values from being displayed.

Submission lifecycle and error handling

  • Replaces the single loading state with explicit transaction status updates throughout the submission lifecycle:

    • Submitted
    • Pending confirmation
    • Confirmed / Failed
  • Preserves the existing polling timeout (30 attempts / ~30 seconds).

  • Replaces raw XDR and HostError payloads with human-readable error messages wherever possible, while falling back to a concise generic message when a specific cause cannot be determined.

Test Plan

  • Load a contract containing read-only functions (for example, balance or get) and verify functions are classified immediately.
  • Load a contract with state-changing functions, simulate a transaction, verify the estimated fee is displayed, and confirm it clears when inputs change.
  • Submit a successful transaction and verify the status transitions from SubmittedPending confirmationConfirmed.
  • Submit a transaction that fails (for example, invalid inputs or insufficient balance) and verify the user receives a readable error message instead of raw JSON or XDR output.
  • Run npm test and verify all existing tests pass.
  • Run npm run build and verify the project compiles without TypeScript errors.

- Derive isReadOnly from the SorobanDataBuilder footprint returned by
  simulateCall; emit null from the parser instead of hardcoding false
- Eagerly probe all primitive-param functions on contract load using
  dummy args; Struct/Enum/Map params are skipped and stay unknown
- Hide Submit for confirmed read-only functions, show read only badge
  in the list, and sort write → unknown → read-only
- Capture minResourceFee from simulation response; total fee shown is
  minResourceFee + BASE_FEE, matching what prepareTransaction signs
- Display fee in TxResult for mutating functions only; clears on
  function change, input edit, Clear, or new simulation
- Fix stale result panel when switching functions
- `invokeCall` fires `submitted → pending → confirmed/failed` callbacks during polling; `TxResult` renders live status with a spinner or status dot

- All error surfaces now return plain English: HostError diagnostic dumps (`Contract error: Check your inputs`), XDR result codes, and pre-submission rejections are each parsed before reaching the UI

- 14 new tests covering status sequences, 30-poll timeout, send/on-chain failures, and simulate error parsing (42 total)
…n-Contract-Explorer into call-lifecycle-overhaul
@vercel

vercel Bot commented Jun 30, 2026

Copy link
Copy Markdown

@Alanwiz00 is attempting to deploy a commit to the raymondabiola's projects Team on Vercel.

A member of the Team first needs to authorize it.

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.

Overhaul the call lifecycle: read-only detection, fee estimation, and submission progress

1 participant