Skip to content

Commit

Permalink
Merge pull request #71 from Concordium/support-integer
Browse files Browse the repository at this point in the history
Support integer type in JSON schema.
  • Loading branch information
abizjak authored Aug 31, 2023
2 parents 522248d + a4e008a commit 12218d4
Show file tree
Hide file tree
Showing 7 changed files with 15 additions and 10 deletions.
2 changes: 1 addition & 1 deletion services/web3id-issuer/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions test-tools/issuer-front-end/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
## 1.0.9

- Change to use a hexString for the auxiliary data.
- Support 'integer' type in the schema.

## 1.0.8

Expand Down
8 changes: 4 additions & 4 deletions test-tools/issuer-front-end/src/Main.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ function attributeInputPlaceHolder(details: AttributeDetails): string {
if (details.type === 'date-time') {
return '2023-08-30T06:22:46Z';
}
if (details.type === 'number') {
if (details.type === 'number' || details.type === 'integer') {
return '1234';
}
return 'myString';
Expand Down Expand Up @@ -181,7 +181,7 @@ function parseAttributesFromForm(
} else if (obj.value !== undefined) {
if (obj.type === 'string') {
attributes[obj.tag] = obj.value;
} else if (obj.type === 'number') {
} 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());
Expand All @@ -193,10 +193,10 @@ function parseAttributesFromForm(
attributes[obj.tag] = date;
} else {
setParsingError(
`Attribute ${obj.tag} has type ${obj.type}. Only the types string/number and date-time are supported.`
`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 and date-time are supported.`
`Attribute ${obj.tag} has type ${obj.type}. Only the types string/number/integer and date-time are supported.`
);
}
}
Expand Down
2 changes: 1 addition & 1 deletion test-tools/issuer-front-end/src/constants.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { BrowserWalletConnector, ephemeralConnectorType } from '@concordium/react-components';
import moment from 'moment';

export const EXAMPLE_CREDENTIAL_SCHEMA = `https://raw.githubusercontent.com/Concordium/concordium-web3id/ac803895b1ffaa50888cfc6667331f6ebb0b889e/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
4 changes: 4 additions & 0 deletions test-tools/proof-explorer/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
## Unreleased changes.

## 1.0.3

Support 'integer' type in the schema.

## 1.0.2

Add support for date-time attributes.
Expand Down
2 changes: 1 addition & 1 deletion test-tools/proof-explorer/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "proof-explorer",
"license": "Apache-2.0",
"version": "1.0.2",
"version": "1.0.3",
"packageManager": "[email protected]",
"dependencies": {
"@concordium/browser-wallet-api-helpers": "2.6.0",
Expand Down
6 changes: 3 additions & 3 deletions test-tools/proof-explorer/src/Root.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -416,13 +416,13 @@ function AttributeInRange({ setStatement, attributeOptions }: RevealAttributePro

const onClickAdd: MouseEventHandler<HTMLButtonElement> = () => {
let lower_bound = lower[0];
if (lower[1] == 'number') {
if (lower[1] === 'number' || lower[1] === 'integer') {
lower_bound = BigInt(lower[0]);
} else if (lower[1] == 'date-time') {
lower_bound = new Date(lower[0].trim());
}
let upper_bound = upper[0];
if (upper[1] == 'number') {
if (upper[1] === 'number' || upper[1] === 'integer') {
upper_bound = BigInt(upper[0]);
} else if (upper[1] == 'date-time') {
upper_bound = new Date(upper[0].trim());
Expand Down Expand Up @@ -488,7 +488,7 @@ function AttributeInSet({ member, setStatement, attributeOptions }: SetMembershi
};

let proof_set = set.split(',').map((s) => s.trim());
if (selected[1] == 'number') {
if (selected[1] === 'number' || selected[1] === 'integer') {
proof_set = proof_set.map((x) => BigInt(x));
} else if (selected[1] == 'date-time') {
proof_set = proof_set.map((x) => new Date(x.trim()));
Expand Down

0 comments on commit 12218d4

Please sign in to comment.