CLI: ScVal and ScType::Result ambiguity

Open
#562 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
5/5
Estimated time
Over a week
Newbie friendliness
30/100
Issue type
Feature
Clarity
Mostly clear
Activity status
Stale
Tech stack
rust
Domain
cli

Research direction

Start by tracing the CLI's ScVal and ScType handling for Result values and the XDR-to-JSON path. Determine how a two-element vector containing void or a value would distinguish Ok from Err, and document the required behavior for both arbitrary ScVal errors and enum values.

Written by the indexing model from the issue text.

Description

Currently Results are not handled well if not at all. One issue with implementing XDR -> JSON for results is that there is no notion of an error type in ScVal. And since the error type in a result type can be any ScVal there is no way to tell the difference between the two.

Example:

In contract

fn foo() -> Result<String, String> {..}

While currently most errors are const enums, this is still valid. Furthermore, we could return a const enum as the Ok value.

Thus I suggest that we encode results in ScVal as a vector of two elements which are void or a value. E.i. as two options. This would allow determining if an Ok or Err was returned.

Dominant language
Rust
Stars
123
Forks
141
Avg merge
2d 21h
Merged PRs (30d)
17

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from stellar/stellar-cli

All issues in stellar/stellar-cli

Similar issues

More Rust issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.