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

Higher order interfaces to wallet.contents #89

Open
OR13 opened this issue Apr 16, 2021 · 0 comments
Open

Higher order interfaces to wallet.contents #89

OR13 opened this issue Apr 16, 2021 · 0 comments

Comments

@OR13
Copy link
Collaborator

OR13 commented Apr 16, 2021

Consider get, set, and Object.values.

In the javascript wallet interfaces we sometimes assume local objects, in ways that make it harder to integrate with external APIs, @sudeshrshetty you pointed this out a while back and we dropped the map / reduces query interfaces... but we still have a problem with this in the sample implementation.

All over our code we are doing things like this:

const myDidKeys = wallet.contents.filter(onlyMyDid);

There are some dangerous assumption hidden in here, like that wallet.contents might not be fresh...

This format also conflicts some with the wallet persistence mechanisms like EDVs, Transmute's current solution to this works, but its not super performant.

I'd like to explore alternatives for contents in this issue with an eye towards JSON-LD purity and async persistence.

  1. A filter is a query, we should avoid any kind of direct array accesss

I think this is the biggest problem, once you start assuming you have an array, you stop defining the higher order interfaces you need, and then you can't get rid of the array assumption.

  1. Wallet.contents ~== wallet.getAllContentAsync

This is a pretty unreasonable assumption to make in any environment.

  1. get / set map to key value systems

can we expose better lower level interfaces than add / remove, that teach developers how to organize content better?

  1. Stateful operations are really hard right now

In a lot of places in our code, we are doing things like this:

await wallet.syncWithEdv(...) // setup wallet state
await wallet.performStatefulProtocolOperation(...)
await wallet.syncWithEdv(...) // persist state from operation above

^ the worst part of this is the assumption about "setup state"... for example, what if critical objects needed by performStatefulProtocolOperation are not present? then they need to be created first... but what if they can't be created?
we are often searching in an array of objects to answer these questions... there must be a better way.

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

1 participant