Skip to content
This repository has been archived by the owner on Aug 3, 2021. It is now read-only.

fix: matched searchCredsForProofReq method types to node wrapper #56

Merged
merged 2 commits into from
Jun 13, 2021

Conversation

JamesKEbert
Copy link
Contributor

The IndySDK Node wrapper extraQuery type in the method proverSearchCredentialsForProofReq differs from the Android and iOS types. Node allows for the parameter to be either a JSON object or null, while Java requires it to be not-null:

Possible Unhandled Promise Rejection (id: 6):
Object {
  "indyBacktrace": "",
  "indyCode": 113,
  "indyMessage": "Error: Invalid structure
  Caused by: Invalid ProofRequestExtraQuery json has been passed
  Caused by: invalid type: null, expected a map at line 1 column 4
",
  "indyName": "CommonInvalidStructure",
  "message": "CommonInvalidStructure",
  "name": "IndyError",
}

Since the tests in AFJ use the Node wrapper they didn't uncover this issue until I tried to use it from a React Native perspective. I opted to adjust the method here to align with the Node types. I'd be happy to take a different approach if desired though.

Signed-off-by: James Ebert <jamesebert.k@gmail.com>
Copy link
Contributor

@TimoGlastra TimoGlastra left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice :)

src/index.js Outdated
return await IndySdk.proverSearchCredentialsForProofReq(
wh,
JSON.stringify(proofRequest),
JSON.stringify(extraQuery)
JSON.stringify(extraQuery ? extraQuery : {})
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
JSON.stringify(extraQuery ? extraQuery : {})
JSON.stringify(extraQuery || {})

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe even JSON.stringify(extraQuery ?? {}) but I'm not sure if it'll be transpiled correctly with the current target 🤔

Copy link
Contributor

@TimoGlastra TimoGlastra Jun 11, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That won't work if you pass null

Edit: it will. My bad

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice suggestions here! I updated to @jakubkoci's suggestion, tested in RN and pushed.

Signed-off-by: James Ebert <jamesebert.k@gmail.com>
@jakubkoci jakubkoci merged commit cfa17b9 into AbsaOSS:master Jun 13, 2021
jakubkoci pushed a commit that referenced this pull request Jul 14, 2021
Signed-off-by: James Ebert <jamesebert.k@gmail.com>
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants