Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support Result<T, E> type in typegen #2190

Closed
spacedragon opened this issue Apr 28, 2024 · 4 comments · Fixed by #2258
Closed

Support Result<T, E> type in typegen #2190

spacedragon opened this issue Apr 28, 2024 · 4 comments · Fixed by #2258
Assignees
Labels

Comments

@spacedragon
Copy link

What version of fuels-ts are you using?

latest

Steps to Reproduce

image

Expected Behavior

The correct code is

export type ResultInput<T,E> = Enum<{ Ok: T, Err: E }>;
export type ResultOutput<T,E>=  ResultInput<T,E>;

Actual Behavior

export type ResultInput = Enum<{ Ok: T, Err: E }>;
export type ResultOutput=  ResultInput;
@nedsalk

This comment was marked as outdated.

@nedsalk nedsalk added the awaiting we need further input from the author label May 2, 2024
@nedsalk
Copy link
Contributor

nedsalk commented May 6, 2024

@spacedragon I realized now that I misread the error you reported here. What you reported indeed seems off. Can you share the ABI which led to this problem?

@spacedragon
Copy link
Author

Made some small changes to the counter example from the starter guide, following is the sway code

contract;

pub struct Foo {
    bar: u64,
    baz: bool
}

enum ColorError {
    Blue: (),
    Green: (),
    Red: (),
    Other: (),
}

storage {
    counter: u64 = 0,
    foo: Foo= Foo {
        bar: 0,
        baz: false
    },
}

abi Counter {
    #[storage(read, write)]
    fn increment(add: u32, two: u64, three: b256) -> u64;

    #[storage(read)]
    fn count() -> u64;

    #[storage(read, write)]
    fn complex(foo: Foo, option: Option<str[1]>) -> Result<Foo, ColorError>;
}

@nedsalk nedsalk changed the title typegen code of enum type should have generic parameters Support Result<T, E> type in typegen May 7, 2024
@nedsalk
Copy link
Contributor

nedsalk commented May 7, 2024

@spacedragon Thanks for the report and the ABI, it is indeed an issue.

@nedsalk nedsalk removed the awaiting we need further input from the author label May 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants