-
Notifications
You must be signed in to change notification settings - Fork 83
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
Mostly typed interface/trait for BaseLedger #815
Comments
@Patrik-Stas unsure if this would be a good first issue or if the types are too complex?? any thoughts? It might be fine |
I think it's alright, you wrote really nice description, but before anyone dives into this, one thing we should clarify:
So perhaps What do you think? |
hmmm, using Redefining your own types is a pattern I've seen in AFJ; E.g. this interface is equivalent to some parts of our |
A part that I'm struggling a bit with is how complicated the structures really need to be. indy-data-types complicates things by putting "Schema" in an enum and having an enum variant of SchemaV1 so that they can majorly change the Schema shape in the future if they want... But I'm not sure if we necessarily need to do the same. AFJ keeps their schema structure simple;
And the more recent anoncreds-rs defines it's own data type for schema too, which simplifies the structure as well:
|
btw fair enough blocking #814 for a resolution on this typing re-using idea ^. But I'm unsure if anyone exports types for wallet structures. There isn't many types in BaseWallet, and they aren't anyway near the complexity of ledger and anoncreds types, so I think it would make sense if aries_vcx_core owned the BaseWallet types, even if reusing types is a possibility. |
I wouldn't consider this "forcing implementation details", it's just data models. Currently we only deal with indy, so if you were to create our own returns types for these interfaces, we could literally just copy-paste content of
Not quite, I believe what's happening there is they are a step ahead of us terms of the interface for ledger interaction. The code you linked seem to return more general structures returned by "anoncreds resolver", similar to "did resolver" - have a look at https://hyperledger.github.io/anoncreds-methods-registry/. It's same idea like DID Methods, but for schemas/cred-defs/revocation-registries. You can have revocation registry on Hedera blockchain for example. |
@gmulhearn but eventually we would end up following similar approach like AFJ you linked, something like
That would be important step toward https://github.com/hyperledger/aries-vcx/blob/main/docs/ROADMAP_2023.md#ledger-agnosticity |
Oh nice, yeah I think I agree. Currently thinking I'd prefer copy pasting indy-data-types structs, rather than having them exported/used from the real indy-data-types crate. Let me think about it a little more, but it would be ideal if aries_vcx_core has a very small dependency tree (when no features are enabled). |
I spoke with @Patrik-Stas further about BaseWallet types. Given that they are quite simple types and that there possibly isn't any types we could re-use/export anyway, the BaseWallet typing work can go ahead without concern for the discussion happening here |
I'd actually like to pick this up next in the upcoming days. The idea would be to have a look at all these traits and use stronger typing for their arguments/return values. I think the way to go about it would be through associated types which would be declared when one of the traits is implemented on a specific type. This way, the trait itself is not tied to any implementation, while something like I'll be drafting something soon enough so I can paint a clearer picture. |
Kk, awesome. I would be keen to hear what the approach will be. Sounds like it could be way over-complicating things.. but I'll hear you out! Haha |
This has been implemented recently during
|
Similar to #814
Context
In
aries_vcx_core/src/ledger/base_ledger.rs
a traitBaseLedger
is defined. WhenBaseLedger
was originally defined, it kept the implementation 'simple' by taking and returning structures in the form of JSON Strings rather than typed ruststruct
s. Now thatBaseLedger
is well integrated, we should go back and properly add types to theBaseLedger
interface.Requirements
BaseLedger
should be replaced with rust structs.BaseLedger
(currently justIndySdkLedger
andIndyVdrLedger
) should be updated to use the new types and translate them appropriatelyBaseLedger
in the code base should be updated to use the new types rather than the JSON stringsjson
in the name signature can be renamed to remove the json. e.g.:get_rev_reg_def_json
->get_rev_reg_def
Methods in Scope
Some methods that return raw request JSONs are too complex to be typed just yet. As such, this issue is only focused on typing the following methods:
get_schema
get_cred_def
get_rev_reg_def_json
get_rev_reg_delta_json
get_rev_reg
Examples:
Example 1:
take this method;
this returns a JSON string of the following format:
a new type should be defined;
pub struct Schema
and given a structure which represents this JSON (e.g. see derived fromlibvdrtools
):Tips
Since
IndySdkLedger
is the primary implementation ofBaseLedger
currently, it's easiest to drill into the libvdrtools implementations for information about what the underlying JSON type should be. The information is typically contained in the string doc above the vdrtools method. Some methods are implemented byIndyVdrLedger
too, which can be used to extract type information.The text was updated successfully, but these errors were encountered: