Skip to content

Commit

Permalink
Merge pull request #82 from Concordium/support-wallet-1.1.6
Browse files Browse the repository at this point in the history
Support wallet version 1.1.6.
  • Loading branch information
abizjak authored Sep 5, 2023
2 parents 12218d4 + 1e19fb7 commit 7972bd7
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 53 deletions.
5 changes: 5 additions & 0 deletions test-tools/issuer-front-end/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
## Unreleased changes

## 1.0.10

- Support new date-time format for browser wallet 1.1.6.
- Allow sending attributes where the attribute type is not recognized.

## 1.0.9

- Change to use a hexString for the auxiliary data.
Expand Down
8 changes: 4 additions & 4 deletions test-tools/issuer-front-end/package.json
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
{
"name": "issuer-front-end",
"packageManager": "[email protected]",
"version": "1.0.9",
"version": "1.0.10",
"license": "Apache-2.0",
"engines": {
"node": ">=16.x"
},
"dependencies": {
"@concordium/browser-wallet-api-helpers": "2.6.0",
"@concordium/browser-wallet-api-helpers": "2.7.0",
"@concordium/react-components": "^0.3.0",
"@concordium/wallet-connectors": "^0.3.1",
"@concordium/web-sdk": "^6.1.1",
"@concordium/web-sdk": "^6.3.0",
"@walletconnect/types": "^2.1.4",
"eslint": "^8.37.0",
"json-bigint": "^1.0.0",
Expand All @@ -21,7 +21,7 @@
"react-switch": "^7.0.0"
},
"resolutions": {
"@concordium/web-sdk": "^6.1.1"
"@concordium/web-sdk": "^6.3.0"
},
"devDependencies": {
"@craftamap/esbuild-plugin-html": "^0.4.0",
Expand Down
42 changes: 10 additions & 32 deletions test-tools/issuer-front-end/src/Main.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -58,32 +58,9 @@ type SchemaRef = {
};

interface Attributes {
[key: string]: string | bigint | Date;
}

interface AttributeJSON {
[key: string]: string | bigint | { type: 'date-time'; timestamp: string };
}

// Transform attributes into the JSON format where date-time attributes
// are represented as an object.
function transformAttributes(attributes: Attributes): AttributeJSON {
const r: AttributeJSON = {};
const attrs = Object.keys(attributes);
attrs.forEach((key) => {
const v = attributes[key];
if (v instanceof Date) {
r[key] = {
type: 'date-time',
timestamp: v.toISOString(),
};
} else {
r[key] = v;
}
});
return r;
}

function attributeInputPlaceHolder(details: AttributeDetails): string {
if (details.type === 'date-time') {
return '2023-08-30T06:22:46Z';
Expand Down Expand Up @@ -181,23 +158,24 @@ function parseAttributesFromForm(
} else if (obj.value !== undefined) {
if (obj.type === 'string') {
attributes[obj.tag] = obj.value;
} else if (obj.type === 'number' || obj.type == 'integer') {
} else if (obj.type === 'number' || obj.type === 'integer') {
attributes[obj.tag] = BigInt(obj.value);
} else if (obj.type === 'date-time') {
const date = new Date(obj.value.trim());
if (Number.isNaN(date.getTime())) {
const msg = `Unable to parse string "${obj.value.trim()}" as a date.`;
setParsingError(msg);
// throw new Error(msg);
}
attributes[obj.tag] = date;
attributes[obj.tag] = {
type: 'date-time',
timestamp: obj.value.trim(),
};
} else {
setParsingError(
`Attribute ${obj.tag} has type ${obj.type}. Only the types string/number/integer and date-time are supported.`
);
throw new Error(
`Attribute ${obj.tag} has type ${obj.type}. Only the types string/number/integer and date-time are supported.`
);
// still set the value so that we can test sending bogus data to the wallet.
attributes[obj.tag] = obj.value;
}
}
});
Expand Down Expand Up @@ -935,7 +913,7 @@ export default function Main(props: WalletConnectionProps) {
);

const commitments = {
attributes: transformAttributes(attributes),
attributes,
holderId: publicKeyOfCredential,
issuer: {
index: credentialRegistryContratIndex,
Expand Down Expand Up @@ -1484,7 +1462,7 @@ export default function Main(props: WalletConnectionProps) {
// Issuer does not register credential here but instead when the next button is pressed.

const commitments = {
attributes: transformAttributes(attributes),
attributes,
holderId: publicKeyOfCredential,
issuer: {
index: credentialRegistryContratIndex,
Expand Down Expand Up @@ -1992,7 +1970,7 @@ export default function Main(props: WalletConnectionProps) {
);

const commitments = {
attributes: transformAttributes(attributes),
attributes,
holderId: publicKeyOfCredential,
issuer: {
index: credentialRegistryContratIndex,
Expand Down
3 changes: 2 additions & 1 deletion test-tools/issuer-front-end/src/constants.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { BrowserWalletConnector, ephemeralConnectorType } from '@concordium/react-components';
import moment from 'moment';

export const EXAMPLE_CREDENTIAL_SCHEMA = 'https://raw.githubusercontent.com/Concordium/concordium-web3id/522248d445cea0362f2c8f40c2a64a794f39b2c9/examples/json-schemas/education-certificate/JsonSchema2023-education-certificate.json';
export const EXAMPLE_CREDENTIAL_SCHEMA =
'https://raw.githubusercontent.com/Concordium/concordium-web3id/522248d445cea0362f2c8f40c2a64a794f39b2c9/examples/json-schemas/education-certificate/JsonSchema2023-education-certificate.json';

export const EXAMPLE_CREDENTIAL_METADATA = `https://gist.githubusercontent.com/abizjak/ff1e90d82c5446c0e001ee6d4e33ea6b/raw/4528363aff42e3ff36b50a1d873287f2f520d610/metadata.json`;

Expand Down
32 changes: 16 additions & 16 deletions test-tools/issuer-front-end/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -256,12 +256,12 @@ __metadata:
languageName: node
linkType: hard

"@concordium/browser-wallet-api-helpers@npm:2.6.0":
version: 2.6.0
resolution: "@concordium/browser-wallet-api-helpers@npm:2.6.0"
"@concordium/browser-wallet-api-helpers@npm:2.7.0":
version: 2.7.0
resolution: "@concordium/browser-wallet-api-helpers@npm:2.7.0"
dependencies:
"@concordium/web-sdk": ^6.1.1
checksum: 9b70bf9f05d428aacfcfff6843fe056b48173e46f32a69129b1feead275f32bdcf83b302c64855adc4e9657512e74da826b4dcac7a29eb1691322587f86c8851
"@concordium/web-sdk": ^6.3.0
checksum: e8e2b6785c1d83f6267d3016f4347e6f2322819926bf68e6297aa1ff8ec68149ea49a503a50d79a8528e51054cd2a043b2dfee2f1639503f2833027807bb5705
languageName: node
linkType: hard

Expand All @@ -274,9 +274,9 @@ __metadata:
languageName: node
linkType: hard

"@concordium/common-sdk@npm:9.1.1":
version: 9.1.1
resolution: "@concordium/common-sdk@npm:9.1.1"
"@concordium/common-sdk@npm:9.3.0":
version: 9.3.0
resolution: "@concordium/common-sdk@npm:9.3.0"
dependencies:
"@concordium/rust-bindings": 1.2.0
"@grpc/grpc-js": ^1.3.4
Expand All @@ -291,7 +291,7 @@ __metadata:
iso-3166-1: ^2.1.1
json-bigint: ^1.0.0
uuid: ^8.3.2
checksum: e7f43e085b968e9772f2559b2530bca59a9aab426332c3e088f266a76bc1e913bedff097aa61bc5a9c5ddb78db4decf2fd6a027d7231e95fcb368fe41f2820c8
checksum: 7457c54948feba0e6ad5e6e591c292300fe6457d77235f4aa0d63efc9328bb63a103144502962b53bac323d98af4407b7322bd8c74ad05252329d9ef9c1ad5f3
languageName: node
linkType: hard

Expand Down Expand Up @@ -324,17 +324,17 @@ __metadata:
languageName: node
linkType: hard

"@concordium/web-sdk@npm:^6.1.1":
version: 6.1.1
resolution: "@concordium/web-sdk@npm:6.1.1"
"@concordium/web-sdk@npm:^6.3.0":
version: 6.3.0
resolution: "@concordium/web-sdk@npm:6.3.0"
dependencies:
"@concordium/common-sdk": 9.1.1
"@concordium/common-sdk": 9.3.0
"@concordium/rust-bindings": 1.2.0
"@grpc/grpc-js": ^1.3.4
"@protobuf-ts/grpcweb-transport": ^2.8.2
buffer: ^6.0.3
process: ^0.11.10
checksum: 85fa565d4ea9e6dfbc7b924b96e511fdb8094d7d3fdbc733204e65495f1969f9a9dd13a3e869c6b5e2501d1b65e1eb7296f282e78b456d3f03d0fac2c101ccad
checksum: 86b069988c88e148490dd12b8d0c2bcbe954dee67c4074ec4965a491ab907c5ffba2a76da53479802605313f204fc6dfc0b0e3033fc186391ae3fe3a21ca6796
languageName: node
linkType: hard

Expand Down Expand Up @@ -5262,10 +5262,10 @@ cors@latest:
version: 0.0.0-use.local
resolution: "issuer-front-end@workspace:."
dependencies:
"@concordium/browser-wallet-api-helpers": 2.6.0
"@concordium/browser-wallet-api-helpers": 2.7.0
"@concordium/react-components": ^0.3.0
"@concordium/wallet-connectors": ^0.3.1
"@concordium/web-sdk": ^6.1.1
"@concordium/web-sdk": ^6.3.0
"@craftamap/esbuild-plugin-html": ^0.4.0
"@types/json-bigint": ^1.0.1
"@types/node": ^18.7.23
Expand Down

0 comments on commit 7972bd7

Please sign in to comment.