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

[react-hooks] agent returned from useAgent should not be optional #72

Open
TimoGlastra opened this issue Nov 7, 2021 · 1 comment
Open

Comments

@TimoGlastra
Copy link
Contributor

It makes for a (IMO) very cluncky API. E.g the following code

const retrievedCreds = await agent?.proofs?.getRequestedCredentialsForProofRequest(
   proof?.requestMessage?.indyProofRequest,
   undefined
)

if (!retrievedCreds) {
   throw new Error('Retrieved creds not found')
}

could be reduced to the following

const retrievedCreds = await agent.proofs.getRequestedCredentialsForProofRequest(
  proof?.requestMessage?.indyProofRequest,
  undefined
)

if agent was always of type Agent.

I think we could throw an error in useAgent if it is not available yet? Or we make sure you can pass a uninitalized agent to the agent provider so the value is at least defined

@TimoGlastra
Copy link
Contributor Author

cc @JamesKEbert @NeilSMyers

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant