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

Commit

Permalink
Fix serialization of parameters and parsing of result in requestVerif…
Browse files Browse the repository at this point in the history
…iablePresentation (#62)

## Purpose
Fix an issue with the request parameters and parsing of the result of
the request in `requestVerifiablePresentation`. We have to wrap the
parameters and the result to ensure that WalletConnect does not attempt
to do any parsing on the JSON as it will fail on bigints.

## Changes
- Wrap request parameters and update result type to a wrapper as well
(this matches what is now done in the CryptoX wallet).

## Checklist

- [x] My code follows the style of this project.
- [x] The code compiles without warnings.
- [x] I have performed a self-review of the changes.
- [x] I have documented my code, in particular the intent of the
      hard-to-understand areas.
- [x] (If necessary) I have updated the CHANGELOG.
  • Loading branch information
orhoj authored Mar 20, 2024
2 parents b5ebf2b + 670c29b commit 130675b
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 3 deletions.
6 changes: 6 additions & 0 deletions packages/wallet-connectors/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased]

### Fixed

- Fixed serialization of parameters in `requestVerifiablePresentation` and parsing of the result of the request.

## [0.5.0] - 2024-03-13

### Added
Expand Down
7 changes: 5 additions & 2 deletions packages/wallet-connectors/src/WalletConnect.ts
Original file line number Diff line number Diff line change
Expand Up @@ -302,14 +302,17 @@ export class WalletConnectConnection implements WalletConnection {
challenge: string,
credentialStatements: CredentialStatements
): Promise<VerifiablePresentation> {
return this.connector.client.request<VerifiablePresentation>({
const paramsJson = jsonUnwrapStringify({ challenge, credentialStatements });
const params = { paramsJson };
const result = await this.connector.client.request<{ verifiablePresentationJson: string }>({
topic: this.session.topic,
request: {
method: 'request_verifiable_presentation',
params: { challenge, credentialStatements },
params,
},
chainId: this.chainId,
});
return VerifiablePresentation.fromString(result.verifiablePresentationJson);
}

async disconnect() {
Expand Down
2 changes: 1 addition & 1 deletion samples/proofs/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ function Main(props: WalletConnectionProps) {
<Card>
<Card.Header>Verifiable presentation</Card.Header>
<Card.Body>
<Card.Text>{JSON.stringify(verifiablePresentation)}</Card.Text>
<Card.Text>{verifiablePresentation.toString()}</Card.Text>
</Card.Body>
</Card>
)}
Expand Down

0 comments on commit 130675b

Please sign in to comment.