Skip to content

Commit d2061dd

Browse files
committed
clean up contract move generated types
1 parent 3ea7df8 commit d2061dd

File tree

4 files changed

+32
-13
lines changed

4 files changed

+32
-13
lines changed

contracts/DIDStampVCVerifier.sol

+2-6
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@ import "@openzeppelin/contracts/utils/cryptography/ECDSA.sol";
55
import { VcVerifier } from "./VCVerifier.sol";
66
import { DIDpkhAdapter } from "./DIDpkhAdapter.sol";
77

8-
import "hardhat/console.sol";
9-
108
struct CredentialSubject {
119
// underscored since hash is a reserved keyword
1210
string _hash;
@@ -111,12 +109,10 @@ contract DIDStampVcVerifier is VcVerifier, DIDpkhAdapter {
111109

112110
address issuerAddress = DIDpkhAdapter.pseudoResolveDidIssuer(document.issuer);
113111

114-
// Here we could check the issuer's address against an on-chain registry.
115-
116112
address recoveredAddress = ECDSA.recover(digest, v, r, s);
117113

118-
console.log("Recovered address: %s", recoveredAddress);
119-
console.log("issuerAddress: %s", issuerAddress);
114+
// Here we could check the issuer's address against an on-chain registry.
115+
// We could provide a verifying contract address when signing the credential which could correspond to this contract
120116
require(recoveredAddress == issuerAddress, "VC verification failed issuer does not match signature");
121117

122118
verifiedStamps[document.credentialSubject.id] = document.credentialSubject._hash;

test/DIDStampVCVerifier.ts

+3-6
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
// import { createCredential } from "../utils/didkitSign"
22
import { ethers } from "hardhat";
33
import { expect } from "chai";
4-
5-
import { DIDStampVcVerifier, DIDStampVcVerifier__factory, DocumentStruct } from "../src/types";
4+
import { DocumentStruct } from "../types"
5+
import { DIDStampVcVerifier, DIDStampVcVerifier__factory } from "../src/types";
66
import { SignerWithAddress } from "@nomiclabs/hardhat-ethers/signers";
77

88
const domainName = "Passport";
@@ -14,7 +14,6 @@ import { normalizeDIDCredential } from "../utils/normalizeDIDCredential";
1414
describe.only("DIDStampVCVerifier", function () {
1515
let signer: SignerWithAddress;
1616
let submitter: SignerWithAddress;
17-
// let chainId: number;
1817
let didStampVCVerifier: DIDStampVcVerifier;
1918

2019
beforeEach(async function () {
@@ -33,11 +32,9 @@ describe.only("DIDStampVCVerifier", function () {
3332

3433
const normalizedDIDCredential = normalizeDIDCredential(DIDKitSignedCredential) as DocumentStruct;
3534

36-
console.log({ normalizedDIDCredential, v, r, s })
37-
3835
await expect(await didStampVCVerifier.connect(submitter).verifyStampVc(normalizedDIDCredential, v, r, s)).to.emit(
3936
didStampVCVerifier,
4037
"Verified",
41-
);;
38+
);
4239
});
4340
})

types/index.ts

+26
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import { PromiseOrValue } from "../src/types/common";
2+
13
export * from "./eip712Types";
24

35
export type ExampleDocument = {
@@ -9,3 +11,27 @@ export type ExampleDocument = {
911
provider: string;
1012
};
1113
};
14+
15+
export type ProofStruct = {
16+
_context: PromiseOrValue<string>;
17+
created: PromiseOrValue<string>;
18+
proofPurpose: PromiseOrValue<string>;
19+
_type: PromiseOrValue<string>;
20+
verificationMethod: PromiseOrValue<string>;
21+
};
22+
23+
export type CredentialSubjectStruct = {
24+
_hash: PromiseOrValue<string>;
25+
id: PromiseOrValue<string>;
26+
provider: PromiseOrValue<string>;
27+
};
28+
29+
export type DocumentStruct = {
30+
_context: PromiseOrValue<string>;
31+
credentialSubject: CredentialSubjectStruct;
32+
expirationDate: PromiseOrValue<string>;
33+
issuanceDate: PromiseOrValue<string>;
34+
issuer: PromiseOrValue<string>;
35+
proof: ProofStruct;
36+
_type: PromiseOrValue<string>[];
37+
};

utils/normalizeDIDCredential.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { DocumentStruct, CredentialSubjectStruct, ProofStruct } from "../src/types";
1+
import { DocumentStruct, CredentialSubjectStruct, ProofStruct } from "../types";
22
export interface DIDCredential {
33
'@context': string;
44
type?: (string)[] | null;

0 commit comments

Comments
 (0)