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

Possible issue in Converter classes for @Constr #436

Open
nemo83 opened this issue Sep 12, 2024 · 2 comments
Open

Possible issue in Converter classes for @Constr #436

nemo83 opened this issue Sep 12, 2024 · 2 comments

Comments

@nemo83
Copy link
Contributor

nemo83 commented Sep 12, 2024

I'm not sure if I'm doing something wrong, but

Given an interface and two class implementations, one empty class and one class w/ one property (as per MyOptional example) https://github.com/bloxbean/cardano-client-lib/blob/fix/blueprint-sum-type-annotation/annotation-processor/src/test/java/com/bloxbean/cardano/client/plutus/annotation/processor/model/MyOptional.java

The code that is autogenerated has error.

Screenshot 2024-09-13 at 00 20 28
@satran004
Copy link
Member

@nemo83 Currently @Constr annotation can only be applied to a class not interface. So in this case, you need to do something like this.

public interface MyOptional {
}

@Constr
public class Some implements MyOptional {
    private BigInteger value;

    public BigInteger getValue() {
        return value;
    }

    public void setValue(BigInteger value) {
        this.value = value;
    }
}
@Constr(alternative = 1)
public class None implements MyOptional {
}

@nemo83
Copy link
Contributor Author

nemo83 commented Sep 13, 2024

What if you MyOption appears in another model object?

EDIT:

By converting MyOption from interface to abstract class seemed to have done the trick.

Anyway, blueprint seems to be able to handle @Constr at interface level when for example you have a Redeemer which can be something like

pub type Redeemer {
Withdraw,
Spend(something: Int)
}

The auto generated code is already:

@Constr
public interface Redeemer {
}

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

No branches or pull requests

2 participants