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
  • Loading branch information
orhoj committed Mar 19, 2024
1 parent b5ebf2b commit 1aa43cd
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 4 deletions.
7 changes: 7 additions & 0 deletions packages/wallet-connectors/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,13 @@ 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
4 changes: 3 additions & 1 deletion packages/wallet-connectors/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,15 @@
"dependencies": {
"@concordium/browser-wallet-api-helpers": "^3.0.0",
"@walletconnect/qrcode-modal": "^1.8.0",
"@walletconnect/sign-client": "^2.1.4"
"@walletconnect/sign-client": "^2.1.4",
"json-bigint": "^1.0.0"
},
"peerDependencies": {
"@concordium/web-sdk": "7.x"
},
"devDependencies": {
"@tsconfig/recommended": "^1.0.1",
"@types/json-bigint": "^1",
"@walletconnect/types": "^2.1.4",
"prettier": "2.8.1",
"typescript": "^5.2.2"
Expand Down
8 changes: 6 additions & 2 deletions packages/wallet-connectors/src/WalletConnect.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import JSONBigInt from 'json-bigint';
import {
SendTransactionInitContractPayload,
SendTransactionPayload,
Expand Down Expand Up @@ -302,14 +303,17 @@ export class WalletConnectConnection implements WalletConnection {
challenge: string,
credentialStatements: CredentialStatements
): Promise<VerifiablePresentation> {
return this.connector.client.request<VerifiablePresentation>({
const serializedParams = JSONBigInt.stringify({ challenge, credentialStatements });
const params = { paramsJson: serializedParams };
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
9 changes: 9 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1723,9 +1723,11 @@ __metadata:
dependencies:
"@concordium/browser-wallet-api-helpers": ^3.0.0
"@tsconfig/recommended": ^1.0.1
"@types/json-bigint": ^1
"@walletconnect/qrcode-modal": ^1.8.0
"@walletconnect/sign-client": ^2.1.4
"@walletconnect/types": ^2.1.4
json-bigint: ^1.0.0
prettier: 2.8.1
typescript: ^5.2.2
peerDependencies:
Expand Down Expand Up @@ -3442,6 +3444,13 @@ __metadata:
languageName: node
linkType: hard

"@types/json-bigint@npm:^1":
version: 1.0.4
resolution: "@types/json-bigint@npm:1.0.4"
checksum: 7aee137b3796121cec755247ea56577611c8e5df89224c567fa71999764d01e12199c4089c6be8a9e4e6a6a8f5c6f309eee2965cc3dd8d576f4c4ba432566041
languageName: node
linkType: hard

"@types/json-schema@npm:*, @types/json-schema@npm:^7.0.12, @types/json-schema@npm:^7.0.4, @types/json-schema@npm:^7.0.5, @types/json-schema@npm:^7.0.8, @types/json-schema@npm:^7.0.9":
version: 7.0.12
resolution: "@types/json-schema@npm:7.0.12"
Expand Down

0 comments on commit 1aa43cd

Please sign in to comment.