From c924455c5d9945b7b5d24c9c31a7f7cd3ec4bee3 Mon Sep 17 00:00:00 2001 From: Ayman Date: Tue, 17 Jun 2025 15:18:12 +0530 Subject: [PATCH 01/25] fix: sdk build configs --- common/package.json | 2 +- sdk/core/index.ts | 8 +- sdk/core/package.json | 28 +- sdk/core/src/SelfBackendVerifier.ts | 6 +- sdk/core/src/index.ts | 2 +- sdk/core/tsconfig.json | 11 +- sdk/qrcode/components/SelfQRcode.tsx | 4 +- sdk/qrcode/package.json | 19 +- sdk/qrcode/tsconfig.json | 15 +- sdk/qrcode/tsup.config.ts | 15 + yarn.lock | 563 ++++++++++++++++++++++++++- 11 files changed, 633 insertions(+), 40 deletions(-) create mode 100644 sdk/qrcode/tsup.config.ts diff --git a/common/package.json b/common/package.json index 689ef27e4..c7692fcea 100644 --- a/common/package.json +++ b/common/package.json @@ -32,7 +32,7 @@ }, "main": "./dist/cjs/index.js", "module": "./dist/esm/index.js", - "types": "./dist/esm/index.d.ts", + "types": "./dist/cjs/index.d.ts", "files": [ "dist/cjs", "dist/esm", diff --git a/sdk/core/index.ts b/sdk/core/index.ts index 7665d12a5..6ac7826b0 100644 --- a/sdk/core/index.ts +++ b/sdk/core/index.ts @@ -1,7 +1,8 @@ -import { SelfBackendVerifier } from './src/SelfBackendVerifier'; -import { getUserIdentifier } from './src/utils/utils'; +import { SelfBackendVerifier } from './src/SelfBackendVerifier.js'; +import { getUserIdentifier } from './src/utils/utils.js'; import { countryCodes } from '@selfxyz/common/constants/constants'; -import { SelfApp, getUniversalLink, SelfAppBuilder } from '@selfxyz/common/utils/appType'; +import { getUniversalLink, SelfAppBuilder } from '@selfxyz/common/utils/appType'; +export type { SelfApp } from '@selfxyz/common/utils/appType'; import { countries } from '@selfxyz/common'; import { hashEndpointWithScope } from '@selfxyz/common/utils/scope'; import { getPackedForbiddenCountries } from '@selfxyz/common/utils/contracts/forbiddenCountries'; @@ -10,7 +11,6 @@ export { SelfBackendVerifier, getUserIdentifier, countryCodes, - SelfApp, getUniversalLink, countries, hashEndpointWithScope, diff --git a/sdk/core/package.json b/sdk/core/package.json index 3f7493c41..19b13fa14 100644 --- a/sdk/core/package.json +++ b/sdk/core/package.json @@ -1,22 +1,33 @@ { "name": "@selfxyz/core", "version": "0.0.25", + "type": "module", "repository": { "type": "git", "url": "https://github.com/selfxyz/self" }, "license": "MIT", "author": "motemotech", - "main": "dist/sdk/core/index.js", - "types": "dist/sdk/core/index.d.ts", + "main": "dist/index.cjs", + "module": "dist/index.js", + "types": "dist/index.d.cts", + "exports": { + ".": { + "import": { + "types": "./dist/index.d.ts", + "default": "./dist/index.js" + }, + "require": { + "types": "./dist/index.d.cts", + "default": "./dist/index.cjs" + } + } + }, "files": [ - "dist", - "common", - "circuits/**/*.json" + "dist" ], "scripts": { - "build": "tsc -build", - "build:deps": "yarn workspaces foreach --from @selfxyz/core --topological-dev --recursive run build", + "build": "tsup index.ts --format cjs,esm --dts --clean --sourcemap", "copy-abi": "bash scripts/copyAbi.sh", "format": "prettier --write .", "install-sdk": "yarn workspaces focus @selfxyz/core", @@ -26,7 +37,7 @@ "types": "yarn build" }, "dependencies": { - "@selfxyz/common": "workspace:^", + "@selfxyz/common": "file:../../common", "@types/uuid": "^10.0.0", "ethers": "^6.13.5", "js-sha1": "^0.7.0", @@ -51,6 +62,7 @@ "prettier": "^3.3.3", "ts-loader": "^9.5.1", "ts-node": "^10.9.2", + "tsup": "^8.5.0", "typescript": "^5.4.5" }, "publishConfig": { diff --git a/sdk/core/src/SelfBackendVerifier.ts b/sdk/core/src/SelfBackendVerifier.ts index 5a644167b..6697a932d 100644 --- a/sdk/core/src/SelfBackendVerifier.ts +++ b/sdk/core/src/SelfBackendVerifier.ts @@ -1,11 +1,11 @@ -import { registryAbi } from './abi/IdentityRegistryImplV1'; -import { verifyAllAbi } from './abi/VerifyAll'; +import { registryAbi } from './abi/IdentityRegistryImplV1.js'; +import { verifyAllAbi } from './abi/VerifyAll.js'; import { REGISTRY_ADDRESS, VERIFYALL_ADDRESS, REGISTRY_ADDRESS_STAGING, VERIFYALL_ADDRESS_STAGING, -} from './constants/contractAddresses'; +} from './constants/contractAddresses.js'; import { ethers } from 'ethers'; import { PublicSignals } from 'snarkjs'; import type { SelfVerificationResult } from '@selfxyz/common/utils/selfAttestation'; diff --git a/sdk/core/src/index.ts b/sdk/core/src/index.ts index 0a1fad6a6..3a5241a45 100644 --- a/sdk/core/src/index.ts +++ b/sdk/core/src/index.ts @@ -1 +1 @@ -export { SelfBackendVerifier } from './SelfBackendVerifier'; +export { SelfBackendVerifier } from './SelfBackendVerifier.js'; diff --git a/sdk/core/tsconfig.json b/sdk/core/tsconfig.json index cd9e9aa27..0a285a9b7 100644 --- a/sdk/core/tsconfig.json +++ b/sdk/core/tsconfig.json @@ -3,8 +3,8 @@ "target": "ES2020", "module": "NodeNext", "declaration": true, - "declarationDir": "./dist", - "outDir": "./dist", + "declarationDir": "./dist/esm", + "outDir": "./dist/esm", "strict": false, "esModuleInterop": true, "skipLibCheck": true, @@ -14,5 +14,10 @@ "baseUrl": "." }, "include": ["index.ts", "src/**/*", "circuits/**/*", "circuits/**/*.json", "utils/utils.ts"], - "exclude": ["node_modules", "**/__tests__/*", "dist"] + "exclude": ["node_modules", "**/__tests__/*", "dist"], + "references": [ + { + "path": "../../common" + } + ] } diff --git a/sdk/qrcode/components/SelfQRcode.tsx b/sdk/qrcode/components/SelfQRcode.tsx index adcc2391c..1e71e0587 100644 --- a/sdk/qrcode/components/SelfQRcode.tsx +++ b/sdk/qrcode/components/SelfQRcode.tsx @@ -1,8 +1,8 @@ import React, { useEffect, useState, useRef } from 'react'; import { BounceLoader } from 'react-spinners'; import Lottie from 'lottie-react'; -import CHECK_ANIMATION from '../animations/check_animation.json'; -import X_ANIMATION from '../animations/x_animation.json'; +import CHECK_ANIMATION from '../animations/check_animation.json' with { type: 'json' }; +import X_ANIMATION from '../animations/x_animation.json' with { type: 'json' }; import LED from './LED.js'; import { REDIRECT_URL, diff --git a/sdk/qrcode/package.json b/sdk/qrcode/package.json index 030b7a161..378922bb7 100644 --- a/sdk/qrcode/package.json +++ b/sdk/qrcode/package.json @@ -9,15 +9,25 @@ "author": "turnoffthiscomputer", "type": "module", "exports": { - ".": "./dist/index.js" + ".": { + "import": { + "types": "./dist/index.d.ts", + "default": "./dist/index.js" + }, + "require": { + "types": "./dist/index.d.ts", + "default": "./dist/index.cjs" + } + } }, - "main": "dist/index.js", - "types": "dist/index.d.ts", + "main": "dist/index.cjs", + "module": "dist/index.js", + "types": "dist/index.d.cts", "files": [ "dist" ], "scripts": { - "build": "tsc --build", + "build": "tsup --config tsup.config.ts", "build:deps": "yarn workspaces foreach --from @selfxyz/qrcode --topological-dev --recursive run build", "format": "prettier --write .", "install-sdk": "yarn workspace focus @selfxyz/qrcode", @@ -55,6 +65,7 @@ "ts-loader": "^9.5.1", "ts-mocha": "^10.0.0", "ts-node": "^10.9.2", + "tsup": "^8.5.0", "typescript": "^5.4.5" }, "peerDependencies": { diff --git a/sdk/qrcode/tsconfig.json b/sdk/qrcode/tsconfig.json index 106c15165..c5ed7cfcb 100644 --- a/sdk/qrcode/tsconfig.json +++ b/sdk/qrcode/tsconfig.json @@ -1,17 +1,17 @@ { "compilerOptions": { - "target": "ES2020", - "module": "Node16", + "target": "ESNext", + "module": "NodeNext", "declaration": true, - "declarationDir": "./dist", - "outDir": "./dist", + "declarationDir": "./dist/esm", + "outDir": "./dist/esm", "strict": false, "esModuleInterop": true, "skipLibCheck": true, "forceConsistentCasingInFileNames": true, "resolveJsonModule": true, "jsx": "react", - "moduleResolution": "node16" + "moduleResolution": "NodeNext" }, "include": [ "animations", @@ -23,5 +23,10 @@ "node_modules", "**/__tests__/*", "dist", + ], + "references": [ + { + "path": "../../common" + } ] } diff --git a/sdk/qrcode/tsup.config.ts b/sdk/qrcode/tsup.config.ts new file mode 100644 index 000000000..4dff6ec9f --- /dev/null +++ b/sdk/qrcode/tsup.config.ts @@ -0,0 +1,15 @@ +import type { Options } from 'tsup'; + +const env = process.env.NODE_ENV; + +export const tsup: Options = { + splitting: true, + clean: true, // clean up the dist folder + dts: true, // generate dts files + format: ['cjs', 'esm'], // generate cjs and esm files + skipNodeModulesBundle: true, + entryPoints: ['index.ts', "animations/**/*", "components/**/*", "utils/**/*"], + watch: env === 'development', + target: 'es2020', + outDir: 'dist', +}; diff --git a/yarn.lock b/yarn.lock index c5ce9db42..27d5a9385 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2326,7 +2326,7 @@ __metadata: languageName: node linkType: hard -"@jridgewell/gen-mapping@npm:^0.3.5": +"@jridgewell/gen-mapping@npm:^0.3.2, @jridgewell/gen-mapping@npm:^0.3.5": version: 0.3.8 resolution: "@jridgewell/gen-mapping@npm:0.3.8" dependencies: @@ -2361,7 +2361,7 @@ __metadata: languageName: node linkType: hard -"@jridgewell/sourcemap-codec@npm:^1.4.10, @jridgewell/sourcemap-codec@npm:^1.4.14": +"@jridgewell/sourcemap-codec@npm:^1.4.10, @jridgewell/sourcemap-codec@npm:^1.4.14, @jridgewell/sourcemap-codec@npm:^1.5.0": version: 1.5.0 resolution: "@jridgewell/sourcemap-codec@npm:1.5.0" checksum: 10c0/2eb864f276eb1096c3c11da3e9bb518f6d9fc0023c78344cdc037abadc725172c70314bdb360f2d4b7bffec7f5d657ce006816bc5d4ecb35e61b66132db00c18 @@ -4005,6 +4005,146 @@ __metadata: languageName: node linkType: hard +"@rollup/rollup-android-arm-eabi@npm:4.43.0": + version: 4.43.0 + resolution: "@rollup/rollup-android-arm-eabi@npm:4.43.0" + conditions: os=android & cpu=arm + languageName: node + linkType: hard + +"@rollup/rollup-android-arm64@npm:4.43.0": + version: 4.43.0 + resolution: "@rollup/rollup-android-arm64@npm:4.43.0" + conditions: os=android & cpu=arm64 + languageName: node + linkType: hard + +"@rollup/rollup-darwin-arm64@npm:4.43.0": + version: 4.43.0 + resolution: "@rollup/rollup-darwin-arm64@npm:4.43.0" + conditions: os=darwin & cpu=arm64 + languageName: node + linkType: hard + +"@rollup/rollup-darwin-x64@npm:4.43.0": + version: 4.43.0 + resolution: "@rollup/rollup-darwin-x64@npm:4.43.0" + conditions: os=darwin & cpu=x64 + languageName: node + linkType: hard + +"@rollup/rollup-freebsd-arm64@npm:4.43.0": + version: 4.43.0 + resolution: "@rollup/rollup-freebsd-arm64@npm:4.43.0" + conditions: os=freebsd & cpu=arm64 + languageName: node + linkType: hard + +"@rollup/rollup-freebsd-x64@npm:4.43.0": + version: 4.43.0 + resolution: "@rollup/rollup-freebsd-x64@npm:4.43.0" + conditions: os=freebsd & cpu=x64 + languageName: node + linkType: hard + +"@rollup/rollup-linux-arm-gnueabihf@npm:4.43.0": + version: 4.43.0 + resolution: "@rollup/rollup-linux-arm-gnueabihf@npm:4.43.0" + conditions: os=linux & cpu=arm & libc=glibc + languageName: node + linkType: hard + +"@rollup/rollup-linux-arm-musleabihf@npm:4.43.0": + version: 4.43.0 + resolution: "@rollup/rollup-linux-arm-musleabihf@npm:4.43.0" + conditions: os=linux & cpu=arm & libc=musl + languageName: node + linkType: hard + +"@rollup/rollup-linux-arm64-gnu@npm:4.43.0": + version: 4.43.0 + resolution: "@rollup/rollup-linux-arm64-gnu@npm:4.43.0" + conditions: os=linux & cpu=arm64 & libc=glibc + languageName: node + linkType: hard + +"@rollup/rollup-linux-arm64-musl@npm:4.43.0": + version: 4.43.0 + resolution: "@rollup/rollup-linux-arm64-musl@npm:4.43.0" + conditions: os=linux & cpu=arm64 & libc=musl + languageName: node + linkType: hard + +"@rollup/rollup-linux-loongarch64-gnu@npm:4.43.0": + version: 4.43.0 + resolution: "@rollup/rollup-linux-loongarch64-gnu@npm:4.43.0" + conditions: os=linux & cpu=loong64 & libc=glibc + languageName: node + linkType: hard + +"@rollup/rollup-linux-powerpc64le-gnu@npm:4.43.0": + version: 4.43.0 + resolution: "@rollup/rollup-linux-powerpc64le-gnu@npm:4.43.0" + conditions: os=linux & cpu=ppc64 & libc=glibc + languageName: node + linkType: hard + +"@rollup/rollup-linux-riscv64-gnu@npm:4.43.0": + version: 4.43.0 + resolution: "@rollup/rollup-linux-riscv64-gnu@npm:4.43.0" + conditions: os=linux & cpu=riscv64 & libc=glibc + languageName: node + linkType: hard + +"@rollup/rollup-linux-riscv64-musl@npm:4.43.0": + version: 4.43.0 + resolution: "@rollup/rollup-linux-riscv64-musl@npm:4.43.0" + conditions: os=linux & cpu=riscv64 & libc=musl + languageName: node + linkType: hard + +"@rollup/rollup-linux-s390x-gnu@npm:4.43.0": + version: 4.43.0 + resolution: "@rollup/rollup-linux-s390x-gnu@npm:4.43.0" + conditions: os=linux & cpu=s390x & libc=glibc + languageName: node + linkType: hard + +"@rollup/rollup-linux-x64-gnu@npm:4.43.0": + version: 4.43.0 + resolution: "@rollup/rollup-linux-x64-gnu@npm:4.43.0" + conditions: os=linux & cpu=x64 & libc=glibc + languageName: node + linkType: hard + +"@rollup/rollup-linux-x64-musl@npm:4.43.0": + version: 4.43.0 + resolution: "@rollup/rollup-linux-x64-musl@npm:4.43.0" + conditions: os=linux & cpu=x64 & libc=musl + languageName: node + linkType: hard + +"@rollup/rollup-win32-arm64-msvc@npm:4.43.0": + version: 4.43.0 + resolution: "@rollup/rollup-win32-arm64-msvc@npm:4.43.0" + conditions: os=win32 & cpu=arm64 + languageName: node + linkType: hard + +"@rollup/rollup-win32-ia32-msvc@npm:4.43.0": + version: 4.43.0 + resolution: "@rollup/rollup-win32-ia32-msvc@npm:4.43.0" + conditions: os=win32 & cpu=ia32 + languageName: node + linkType: hard + +"@rollup/rollup-win32-x64-msvc@npm:4.43.0": + version: 4.43.0 + resolution: "@rollup/rollup-win32-x64-msvc@npm:4.43.0" + conditions: os=win32 & cpu=x64 + languageName: node + linkType: hard + "@scure/base@npm:~1.1.0, @scure/base@npm:~1.1.6": version: 1.1.9 resolution: "@scure/base@npm:1.1.9" @@ -4168,6 +4308,39 @@ __metadata: languageName: unknown linkType: soft +"@selfxyz/common@file:../../common::locator=%40selfxyz%2Fcore%40workspace%3Asdk%2Fcore": + version: 0.0.2 + resolution: "@selfxyz/common@file:../../common#../../common::hash=50993d&locator=%40selfxyz%2Fcore%40workspace%3Asdk%2Fcore" + dependencies: + "@openpassport/zk-kit-imt": "npm:^0.0.5" + "@openpassport/zk-kit-lean-imt": "npm:^0.0.6" + "@openpassport/zk-kit-smt": "npm:^0.0.1" + asn1.js: "npm:^5.4.1" + asn1js: "npm:^3.0.5" + axios: "npm:^1.7.2" + buffer: "npm:^6.0.3" + chai: "npm:^4.3.8" + country-emoji: "npm:^1.5.6" + country-iso-3-to-2: "npm:^1.1.1" + elliptic: "npm:^6.5.5" + fs: "npm:^0.0.1-security" + i18n-iso-countries: "npm:^7.13.0" + js-sha1: "npm:^0.7.0" + js-sha256: "npm:^0.11.0" + js-sha512: "npm:^0.9.0" + json-to-ts: "npm:^2.1.0" + jsrsasign: "npm:^11.1.0" + node-forge: "github:remicolin/forge#17a11a632dd0e50343b3b8393245a2696f78afbb" + path: "npm:^0.12.7" + pkijs: "npm:^3.2.4" + poseidon-lite: "npm:^0.2.0" + snarkjs: "npm:^0.7.5" + typescript-parser: "npm:^2.6.1" + uuid: "npm:^11.0.5" + checksum: 10c0/ed038945ad93e4424658f7cb1fb421696c3c5ececd653a53ec00df592edd5c48ab2e4ea9bb431f032ad9d964a19a417569ff6c6709bbc672dc215b10c60e1b30 + languageName: node + linkType: hard + "@selfxyz/common@workspace:, @selfxyz/common@workspace:^, @selfxyz/common@workspace:common": version: 0.0.0-use.local resolution: "@selfxyz/common@workspace:common" @@ -4263,7 +4436,7 @@ __metadata: version: 0.0.0-use.local resolution: "@selfxyz/core@workspace:sdk/core" dependencies: - "@selfxyz/common": "workspace:^" + "@selfxyz/common": "file:../../common" "@types/chai": "npm:^4.3.6" "@types/chai-as-promised": "npm:^7.1.8" "@types/circomlibjs": "npm:^0.1.6" @@ -4285,6 +4458,7 @@ __metadata: snarkjs: "npm:^0.7.4" ts-loader: "npm:^9.5.1" ts-node: "npm:^10.9.2" + tsup: "npm:^8.5.0" typescript: "npm:^5.4.5" uuid: "npm:^11.1.0" languageName: unknown @@ -4419,6 +4593,7 @@ __metadata: ts-loader: "npm:^9.5.1" ts-mocha: "npm:^10.0.0" ts-node: "npm:^10.9.2" + tsup: "npm:^8.5.0" typescript: "npm:^5.4.5" uuid: "npm:^10.0.0" peerDependencies: @@ -7860,7 +8035,7 @@ __metadata: languageName: node linkType: hard -"@types/estree@npm:*, @types/estree@npm:^1.0.6": +"@types/estree@npm:*, @types/estree@npm:1.0.7, @types/estree@npm:^1.0.6": version: 1.0.7 resolution: "@types/estree@npm:1.0.7" checksum: 10c0/be815254316882f7c40847336cd484c3bc1c3e34f710d197160d455dc9d6d050ffbf4c3bc76585dba86f737f020ab20bdb137ebe0e9116b0c86c7c0342221b8c @@ -9188,6 +9363,13 @@ __metadata: languageName: node linkType: hard +"any-promise@npm:^1.0.0": + version: 1.3.0 + resolution: "any-promise@npm:1.3.0" + checksum: 10c0/60f0298ed34c74fef50daab88e8dab786036ed5a7fad02e012ab57e376e0a0b4b29e83b95ea9b5e7d89df762f5f25119b83e00706ecaccb22cfbacee98d74889 + languageName: node + linkType: hard + "anymatch@npm:^3.0.3, anymatch@npm:~3.1.2": version: 3.1.3 resolution: "anymatch@npm:3.1.3" @@ -10080,6 +10262,17 @@ __metadata: languageName: node linkType: hard +"bundle-require@npm:^5.1.0": + version: 5.1.0 + resolution: "bundle-require@npm:5.1.0" + dependencies: + load-tsconfig: "npm:^0.2.3" + peerDependencies: + esbuild: ">=0.18" + checksum: 10c0/8bff9df68eb686f05af952003c78e70ffed2817968f92aebb2af620cc0b7428c8154df761d28f1b38508532204278950624ef86ce63644013dc57660a9d1810f + languageName: node + linkType: hard + "bytes-iec@npm:^3.1.1": version: 3.1.1 resolution: "bytes-iec@npm:3.1.1" @@ -10101,6 +10294,13 @@ __metadata: languageName: node linkType: hard +"cac@npm:^6.7.14": + version: 6.7.14 + resolution: "cac@npm:6.7.14" + checksum: 10c0/4ee06aaa7bab8981f0d54e5f5f9d4adcd64058e9697563ce336d8a3878ed018ee18ebe5359b2430eceae87e0758e62ea2019c3f52ae6e211b1bd2e133856cd10 + languageName: node + linkType: hard + "cacache@npm:^19.0.1": version: 19.0.1 resolution: "cacache@npm:19.0.1" @@ -10898,6 +11098,13 @@ __metadata: languageName: node linkType: hard +"commander@npm:^4.0.0": + version: 4.1.1 + resolution: "commander@npm:4.1.1" + checksum: 10c0/84a76c08fe6cc08c9c93f62ac573d2907d8e79138999312c92d4155bc2325d487d64d13f669b2000c9f8caf70493c1be2dac74fec3c51d5a04f8bc3ae1830bab + languageName: node + linkType: hard + "commander@npm:^7.2.0": version: 7.2.0 resolution: "commander@npm:7.2.0" @@ -10981,6 +11188,13 @@ __metadata: languageName: node linkType: hard +"confbox@npm:^0.1.8": + version: 0.1.8 + resolution: "confbox@npm:0.1.8" + checksum: 10c0/fc2c68d97cb54d885b10b63e45bd8da83a8a71459d3ecf1825143dd4c7f9f1b696b3283e07d9d12a144c1301c2ebc7842380bdf0014e55acc4ae1c9550102418 + languageName: node + linkType: hard + "connect@npm:^3.6.5": version: 3.7.0 resolution: "connect@npm:3.7.0" @@ -10993,6 +11207,13 @@ __metadata: languageName: node linkType: hard +"consola@npm:^3.4.0": + version: 3.4.2 + resolution: "consola@npm:3.4.2" + checksum: 10c0/7cebe57ecf646ba74b300bcce23bff43034ed6fbec9f7e39c27cee1dc00df8a21cd336b466ad32e304ea70fba04ec9e890c200270de9a526ce021ba8a7e4c11a + languageName: node + linkType: hard + "convert-source-map@npm:^1.7.0": version: 1.9.0 resolution: "convert-source-map@npm:1.9.0" @@ -12075,7 +12296,7 @@ __metadata: languageName: node linkType: hard -"esbuild@npm:~0.25.0": +"esbuild@npm:^0.25.0, esbuild@npm:~0.25.0": version: 0.25.5 resolution: "esbuild@npm:0.25.5" dependencies: @@ -13179,6 +13400,17 @@ __metadata: languageName: node linkType: hard +"fix-dts-default-cjs-exports@npm:^1.0.0": + version: 1.0.1 + resolution: "fix-dts-default-cjs-exports@npm:1.0.1" + dependencies: + magic-string: "npm:^0.30.17" + mlly: "npm:^1.7.4" + rollup: "npm:^4.34.8" + checksum: 10c0/61a3cbe32b6c29df495ef3aded78199fe9dbb52e2801c899fe76d9ca413d3c8c51f79986bac83f8b4b2094ebde883ddcfe47b68ce469806ba13ca6ed4e7cd362 + languageName: node + linkType: hard + "flat-cache@npm:^3.0.4": version: 3.2.0 resolution: "flat-cache@npm:3.2.0" @@ -13661,7 +13893,7 @@ __metadata: languageName: node linkType: hard -"glob@npm:^10.2.2": +"glob@npm:^10.2.2, glob@npm:^10.3.10": version: 10.4.5 resolution: "glob@npm:10.4.5" dependencies: @@ -15445,6 +15677,13 @@ __metadata: languageName: node linkType: hard +"joycon@npm:^3.1.1": + version: 3.1.1 + resolution: "joycon@npm:3.1.1" + checksum: 10c0/131fb1e98c9065d067fd49b6e685487ac4ad4d254191d7aa2c9e3b90f4e9ca70430c43cad001602bdbdabcf58717d3b5c5b7461c1bd8e39478c8de706b3fe6ae + languageName: node + linkType: hard + "js-base64@npm:^3.7.5": version: 3.7.7 resolution: "js-base64@npm:3.7.7" @@ -15886,7 +16125,7 @@ __metadata: languageName: node linkType: hard -"lilconfig@npm:^3.1.3": +"lilconfig@npm:^3.1.1, lilconfig@npm:^3.1.3": version: 3.1.3 resolution: "lilconfig@npm:3.1.3" checksum: 10c0/f5604e7240c5c275743561442fbc5abf2a84ad94da0f5adc71d25e31fa8483048de3dcedcb7a44112a942fed305fd75841cdf6c9681c7f640c63f1049e9a5dcc @@ -15900,6 +16139,13 @@ __metadata: languageName: node linkType: hard +"load-tsconfig@npm:^0.2.3": + version: 0.2.5 + resolution: "load-tsconfig@npm:0.2.5" + checksum: 10c0/bf2823dd26389d3497b6567f07435c5a7a58d9df82e879b0b3892f87d8db26900f84c85bc329ef41c0540c0d6a448d1c23ddc64a80f3ff6838b940f3915a3fcb + languageName: node + linkType: hard + "loader-runner@npm:^4.2.0": version: 4.3.0 resolution: "loader-runner@npm:4.3.0" @@ -16014,6 +16260,13 @@ __metadata: languageName: node linkType: hard +"lodash.sortby@npm:^4.7.0": + version: 4.7.0 + resolution: "lodash.sortby@npm:4.7.0" + checksum: 10c0/fc48fb54ff7669f33bb32997cab9460757ee99fafaf72400b261c3e10fde21538e47d8cfcbe6a25a31bcb5b7b727c27d52626386fc2de24eb059a6d64a89cdf5 + languageName: node + linkType: hard + "lodash.throttle@npm:^4.1.1": version: 4.1.1 resolution: "lodash.throttle@npm:4.1.1" @@ -16183,6 +16436,15 @@ __metadata: languageName: node linkType: hard +"magic-string@npm:^0.30.17": + version: 0.30.17 + resolution: "magic-string@npm:0.30.17" + dependencies: + "@jridgewell/sourcemap-codec": "npm:^1.5.0" + checksum: 10c0/16826e415d04b88378f200fe022b53e638e3838b9e496edda6c0e086d7753a44a6ed187adc72d19f3623810589bf139af1a315541cd6a26ae0771a0193eaf7b8 + languageName: node + linkType: hard + "make-dir@npm:^2.0.0, make-dir@npm:^2.1.0": version: 2.1.0 resolution: "make-dir@npm:2.1.0" @@ -17077,6 +17339,18 @@ __metadata: languageName: node linkType: hard +"mlly@npm:^1.7.4": + version: 1.7.4 + resolution: "mlly@npm:1.7.4" + dependencies: + acorn: "npm:^8.14.0" + pathe: "npm:^2.0.1" + pkg-types: "npm:^1.3.0" + ufo: "npm:^1.5.4" + checksum: 10c0/69e738218a13d6365caf930e0ab4e2b848b84eec261597df9788cefb9930f3e40667be9cb58a4718834ba5f97a6efeef31d3b5a95f4388143fd4e0d0deff72ff + languageName: node + linkType: hard + "mnemonist@npm:^0.38.0": version: 0.38.5 resolution: "mnemonist@npm:0.38.5" @@ -17214,6 +17488,17 @@ __metadata: languageName: node linkType: hard +"mz@npm:^2.7.0": + version: 2.7.0 + resolution: "mz@npm:2.7.0" + dependencies: + any-promise: "npm:^1.0.0" + object-assign: "npm:^4.0.1" + thenify-all: "npm:^1.0.0" + checksum: 10c0/103114e93f87362f0b56ab5b2e7245051ad0276b646e3902c98397d18bb8f4a77f2ea4a2c9d3ad516034ea3a56553b60d3f5f78220001ca4c404bd711bd0af39 + languageName: node + linkType: hard + "nanoassert@npm:^2.0.0": version: 2.0.0 resolution: "nanoassert@npm:2.0.0" @@ -17559,7 +17844,7 @@ __metadata: languageName: node linkType: hard -"object-assign@npm:^4.1.0, object-assign@npm:^4.1.1": +"object-assign@npm:^4.0.1, object-assign@npm:^4.1.0, object-assign@npm:^4.1.1": version: 4.1.1 resolution: "object-assign@npm:4.1.1" checksum: 10c0/1f4df9945120325d041ccf7b86f31e8bcc14e73d29171e37a7903050e96b81323784ec59f93f102ec635bcf6fa8034ba3ea0a8c7e69fa202b87ae3b6cec5a414 @@ -18067,6 +18352,13 @@ __metadata: languageName: node linkType: hard +"pathe@npm:^2.0.1": + version: 2.0.3 + resolution: "pathe@npm:2.0.3" + checksum: 10c0/c118dc5a8b5c4166011b2b70608762e260085180bb9e33e80a50dcdb1e78c010b1624f4280c492c92b05fc276715a4c357d1f9edc570f8f1b3d90b6839ebaca1 + languageName: node + linkType: hard + "pathval@npm:^1.1.1": version: 1.1.1 resolution: "pathval@npm:1.1.1" @@ -18129,7 +18421,7 @@ __metadata: languageName: node linkType: hard -"pirates@npm:^4.0.4, pirates@npm:^4.0.6": +"pirates@npm:^4.0.1, pirates@npm:^4.0.4, pirates@npm:^4.0.6": version: 4.0.7 resolution: "pirates@npm:4.0.7" checksum: 10c0/a51f108dd811beb779d58a76864bbd49e239fa40c7984cd11596c75a121a8cc789f1c8971d8bb15f0dbf9d48b76c05bb62fcbce840f89b688c0fa64b37e8478a @@ -18154,6 +18446,17 @@ __metadata: languageName: node linkType: hard +"pkg-types@npm:^1.3.0": + version: 1.3.1 + resolution: "pkg-types@npm:1.3.1" + dependencies: + confbox: "npm:^0.1.8" + mlly: "npm:^1.7.4" + pathe: "npm:^2.0.1" + checksum: 10c0/19e6cb8b66dcc66c89f2344aecfa47f2431c988cfa3366bdfdcfb1dd6695f87dcce37fbd90fe9d1605e2f4440b77f391e83c23255347c35cf84e7fd774d7fcea + languageName: node + linkType: hard + "pkijs@npm:^3.2.4": version: 3.2.5 resolution: "pkijs@npm:3.2.5" @@ -18215,6 +18518,29 @@ __metadata: languageName: node linkType: hard +"postcss-load-config@npm:^6.0.1": + version: 6.0.1 + resolution: "postcss-load-config@npm:6.0.1" + dependencies: + lilconfig: "npm:^3.1.1" + peerDependencies: + jiti: ">=1.21.0" + postcss: ">=8.0.9" + tsx: ^4.8.1 + yaml: ^2.4.2 + peerDependenciesMeta: + jiti: + optional: true + postcss: + optional: true + tsx: + optional: true + yaml: + optional: true + checksum: 10c0/74173a58816dac84e44853f7afbd283f4ef13ca0b6baeba27701214beec33f9e309b128f8102e2b173e8d45ecba45d279a9be94b46bf48d219626aa9b5730848 + languageName: node + linkType: hard + "postinstall-postinstall@npm:^2.1.0": version: 2.1.0 resolution: "postinstall-postinstall@npm:2.1.0" @@ -19589,6 +19915,81 @@ __metadata: languageName: node linkType: hard +"rollup@npm:^4.34.8": + version: 4.43.0 + resolution: "rollup@npm:4.43.0" + dependencies: + "@rollup/rollup-android-arm-eabi": "npm:4.43.0" + "@rollup/rollup-android-arm64": "npm:4.43.0" + "@rollup/rollup-darwin-arm64": "npm:4.43.0" + "@rollup/rollup-darwin-x64": "npm:4.43.0" + "@rollup/rollup-freebsd-arm64": "npm:4.43.0" + "@rollup/rollup-freebsd-x64": "npm:4.43.0" + "@rollup/rollup-linux-arm-gnueabihf": "npm:4.43.0" + "@rollup/rollup-linux-arm-musleabihf": "npm:4.43.0" + "@rollup/rollup-linux-arm64-gnu": "npm:4.43.0" + "@rollup/rollup-linux-arm64-musl": "npm:4.43.0" + "@rollup/rollup-linux-loongarch64-gnu": "npm:4.43.0" + "@rollup/rollup-linux-powerpc64le-gnu": "npm:4.43.0" + "@rollup/rollup-linux-riscv64-gnu": "npm:4.43.0" + "@rollup/rollup-linux-riscv64-musl": "npm:4.43.0" + "@rollup/rollup-linux-s390x-gnu": "npm:4.43.0" + "@rollup/rollup-linux-x64-gnu": "npm:4.43.0" + "@rollup/rollup-linux-x64-musl": "npm:4.43.0" + "@rollup/rollup-win32-arm64-msvc": "npm:4.43.0" + "@rollup/rollup-win32-ia32-msvc": "npm:4.43.0" + "@rollup/rollup-win32-x64-msvc": "npm:4.43.0" + "@types/estree": "npm:1.0.7" + fsevents: "npm:~2.3.2" + dependenciesMeta: + "@rollup/rollup-android-arm-eabi": + optional: true + "@rollup/rollup-android-arm64": + optional: true + "@rollup/rollup-darwin-arm64": + optional: true + "@rollup/rollup-darwin-x64": + optional: true + "@rollup/rollup-freebsd-arm64": + optional: true + "@rollup/rollup-freebsd-x64": + optional: true + "@rollup/rollup-linux-arm-gnueabihf": + optional: true + "@rollup/rollup-linux-arm-musleabihf": + optional: true + "@rollup/rollup-linux-arm64-gnu": + optional: true + "@rollup/rollup-linux-arm64-musl": + optional: true + "@rollup/rollup-linux-loongarch64-gnu": + optional: true + "@rollup/rollup-linux-powerpc64le-gnu": + optional: true + "@rollup/rollup-linux-riscv64-gnu": + optional: true + "@rollup/rollup-linux-riscv64-musl": + optional: true + "@rollup/rollup-linux-s390x-gnu": + optional: true + "@rollup/rollup-linux-x64-gnu": + optional: true + "@rollup/rollup-linux-x64-musl": + optional: true + "@rollup/rollup-win32-arm64-msvc": + optional: true + "@rollup/rollup-win32-ia32-msvc": + optional: true + "@rollup/rollup-win32-x64-msvc": + optional: true + fsevents: + optional: true + bin: + rollup: dist/bin/rollup + checksum: 10c0/a14a16ee5433f9eddfe803ed1a3f4528e3e96f746e55bf88c5482f9a60a4ad61f507b59f46d5d9c8dc98bb7983483e0c94b760ae37c02157eba9da5665c1641b + languageName: node + linkType: hard + "run-parallel@npm:^1.1.9": version: 1.2.0 resolution: "run-parallel@npm:1.2.0" @@ -20332,6 +20733,15 @@ __metadata: languageName: node linkType: hard +"source-map@npm:0.8.0-beta.0": + version: 0.8.0-beta.0 + resolution: "source-map@npm:0.8.0-beta.0" + dependencies: + whatwg-url: "npm:^7.0.0" + checksum: 10c0/fb4d9bde9a9fdb2c29b10e5eae6c71d10e09ef467e1afb75fdec2eb7e11fa5b343a2af553f74f18b695dbc0b81f9da2e9fa3d7a317d5985e9939499ec6087835 + languageName: node + linkType: hard + "source-map@npm:^0.5.6": version: 0.5.7 resolution: "source-map@npm:0.5.7" @@ -20779,6 +21189,24 @@ __metadata: languageName: node linkType: hard +"sucrase@npm:^3.35.0": + version: 3.35.0 + resolution: "sucrase@npm:3.35.0" + dependencies: + "@jridgewell/gen-mapping": "npm:^0.3.2" + commander: "npm:^4.0.0" + glob: "npm:^10.3.10" + lines-and-columns: "npm:^1.1.6" + mz: "npm:^2.7.0" + pirates: "npm:^4.0.1" + ts-interface-checker: "npm:^0.1.9" + bin: + sucrase: bin/sucrase + sucrase-node: bin/sucrase-node + checksum: 10c0/ac85f3359d2c2ecbf5febca6a24ae9bf96c931f05fde533c22a94f59c6a74895e5d5f0e871878dfd59c2697a75ebb04e4b2224ef0bfc24ca1210735c2ec191ef + languageName: node + linkType: hard + "sudo-prompt@npm:^9.0.0": version: 9.2.1 resolution: "sudo-prompt@npm:9.2.1" @@ -21185,6 +21613,24 @@ __metadata: languageName: node linkType: hard +"thenify-all@npm:^1.0.0": + version: 1.6.0 + resolution: "thenify-all@npm:1.6.0" + dependencies: + thenify: "npm:>= 3.1.0 < 4" + checksum: 10c0/9b896a22735e8122754fe70f1d65f7ee691c1d70b1f116fda04fea103d0f9b356e3676cb789506e3909ae0486a79a476e4914b0f92472c2e093d206aed4b7d6b + languageName: node + linkType: hard + +"thenify@npm:>= 3.1.0 < 4": + version: 3.3.1 + resolution: "thenify@npm:3.3.1" + dependencies: + any-promise: "npm:^1.0.0" + checksum: 10c0/f375aeb2b05c100a456a30bc3ed07ef03a39cbdefe02e0403fb714b8c7e57eeaad1a2f5c4ecfb9ce554ce3db9c2b024eba144843cd9e344566d9fcee73b04767 + languageName: node + linkType: hard + "throat@npm:^5.0.0": version: 5.0.0 resolution: "throat@npm:5.0.0" @@ -21225,6 +21671,13 @@ __metadata: languageName: node linkType: hard +"tinyexec@npm:^0.3.2": + version: 0.3.2 + resolution: "tinyexec@npm:0.3.2" + checksum: 10c0/3efbf791a911be0bf0821eab37a3445c2ba07acc1522b1fa84ae1e55f10425076f1290f680286345ed919549ad67527d07281f1c19d584df3b74326909eb1f90 + languageName: node + linkType: hard + "tinyglobby@npm:^0.2.11, tinyglobby@npm:^0.2.12, tinyglobby@npm:^0.2.6": version: 0.2.14 resolution: "tinyglobby@npm:0.2.14" @@ -21290,6 +21743,15 @@ __metadata: languageName: node linkType: hard +"tr46@npm:^1.0.1": + version: 1.0.1 + resolution: "tr46@npm:1.0.1" + dependencies: + punycode: "npm:^2.1.0" + checksum: 10c0/41525c2ccce86e3ef30af6fa5e1464e6d8bb4286a58ea8db09228f598889581ef62347153f6636cd41553dc41685bdfad0a9d032ef58df9fbb0792b3447d0f04 + languageName: node + linkType: hard + "tr46@npm:~0.0.3": version: 0.0.3 resolution: "tr46@npm:0.0.3" @@ -21297,6 +21759,15 @@ __metadata: languageName: node linkType: hard +"tree-kill@npm:^1.2.2": + version: 1.2.2 + resolution: "tree-kill@npm:1.2.2" + bin: + tree-kill: cli.js + checksum: 10c0/7b1b7c7f17608a8f8d20a162e7957ac1ef6cd1636db1aba92f4e072dc31818c2ff0efac1e3d91064ede67ed5dc57c565420531a8134090a12ac10cf792ab14d2 + languageName: node + linkType: hard + "treeify@npm:^1.1.0": version: 1.1.0 resolution: "treeify@npm:1.1.0" @@ -21352,6 +21823,13 @@ __metadata: languageName: node linkType: hard +"ts-interface-checker@npm:^0.1.9": + version: 0.1.13 + resolution: "ts-interface-checker@npm:0.1.13" + checksum: 10c0/232509f1b84192d07b81d1e9b9677088e590ac1303436da1e92b296e9be8e31ea042e3e1fd3d29b1742ad2c959e95afe30f63117b8f1bc3a3850070a5142fea7 + languageName: node + linkType: hard + "ts-loader@npm:^9.5.1": version: 9.5.2 resolution: "ts-loader@npm:9.5.2" @@ -21492,6 +21970,48 @@ __metadata: languageName: node linkType: hard +"tsup@npm:^8.5.0": + version: 8.5.0 + resolution: "tsup@npm:8.5.0" + dependencies: + bundle-require: "npm:^5.1.0" + cac: "npm:^6.7.14" + chokidar: "npm:^4.0.3" + consola: "npm:^3.4.0" + debug: "npm:^4.4.0" + esbuild: "npm:^0.25.0" + fix-dts-default-cjs-exports: "npm:^1.0.0" + joycon: "npm:^3.1.1" + picocolors: "npm:^1.1.1" + postcss-load-config: "npm:^6.0.1" + resolve-from: "npm:^5.0.0" + rollup: "npm:^4.34.8" + source-map: "npm:0.8.0-beta.0" + sucrase: "npm:^3.35.0" + tinyexec: "npm:^0.3.2" + tinyglobby: "npm:^0.2.11" + tree-kill: "npm:^1.2.2" + peerDependencies: + "@microsoft/api-extractor": ^7.36.0 + "@swc/core": ^1 + postcss: ^8.4.12 + typescript: ">=4.5.0" + peerDependenciesMeta: + "@microsoft/api-extractor": + optional: true + "@swc/core": + optional: true + postcss: + optional: true + typescript: + optional: true + bin: + tsup: dist/cli-default.js + tsup-node: dist/cli-node.js + checksum: 10c0/2eddc1138ad992a2e67d826e92e0b0c4f650367355866c77df8368ade9489e0a8bf2b52b352e97fec83dc690af05881c29c489af27acb86ac2cef38b0d029087 + languageName: node + linkType: hard + "tsutils@npm:^3.21.0": version: 3.21.0 resolution: "tsutils@npm:3.21.0" @@ -21743,6 +22263,13 @@ __metadata: languageName: node linkType: hard +"ufo@npm:^1.5.4": + version: 1.6.1 + resolution: "ufo@npm:1.6.1" + checksum: 10c0/5a9f041e5945fba7c189d5410508cbcbefef80b253ed29aa2e1f8a2b86f4bd51af44ee18d4485e6d3468c92be9bf4a42e3a2b72dcaf27ce39ce947ec994f1e6b + languageName: node + linkType: hard + "uglify-js@npm:^3.1.4": version: 3.19.3 resolution: "uglify-js@npm:3.19.3" @@ -22199,6 +22726,13 @@ __metadata: languageName: node linkType: hard +"webidl-conversions@npm:^4.0.2": + version: 4.0.2 + resolution: "webidl-conversions@npm:4.0.2" + checksum: 10c0/def5c5ac3479286dffcb604547628b2e6b46c5c5b8a8cfaa8c71dc3bafc85859bde5fbe89467ff861f571ab38987cf6ab3d6e7c80b39b999e50e803c12f3164f + languageName: node + linkType: hard + "webpack-sources@npm:^3.2.3": version: 3.3.0 resolution: "webpack-sources@npm:3.3.0" @@ -22260,6 +22794,17 @@ __metadata: languageName: node linkType: hard +"whatwg-url@npm:^7.0.0": + version: 7.1.0 + resolution: "whatwg-url@npm:7.1.0" + dependencies: + lodash.sortby: "npm:^4.7.0" + tr46: "npm:^1.0.1" + webidl-conversions: "npm:^4.0.2" + checksum: 10c0/2785fe4647690e5a0225a79509ba5e21fdf4a71f9de3eabdba1192483fe006fc79961198e0b99f82751557309f17fc5a07d4d83c251aa5b2f85ba71e674cbee9 + languageName: node + linkType: hard + "which-boxed-primitive@npm:^1.1.0, which-boxed-primitive@npm:^1.1.1": version: 1.1.1 resolution: "which-boxed-primitive@npm:1.1.1" From e41f98e10c8fcc6c8d85a931ef8ac74678b7e864 Mon Sep 17 00:00:00 2001 From: Ayman Date: Tue, 17 Jun 2025 20:21:31 +0530 Subject: [PATCH 02/25] chore: SelfBackendVerifier (WIP) --- .../contracts/IdentityVerificationHubImpl.ts | 886 ++++++++++++++++++ sdk/core/app/contracts/common.ts | 131 +++ .../IdentityVerificationHubImpl__factory.ts | 836 +++++++++++++++++ sdk/core/app/contracts/factories/index.ts | 4 + sdk/core/app/contracts/index.ts | 6 + sdk/core/package.json | 2 + sdk/core/scripts/copyAbi.sh | 2 +- sdk/core/scripts/fix-imports.js | 26 + sdk/core/src/SelfBackendVerifier.ts | 498 +++++----- .../src/abi/IdentityVerificationHubImpl.json | 809 ++++++++++++++++ .../IdentityVerificationHubImpl.ts | 886 ++++++++++++++++++ sdk/core/src/typechain-types/common.ts | 131 +++ .../IdentityVerificationHubImpl__factory.ts | 836 +++++++++++++++++ .../src/typechain-types/factories/index.ts | 4 + sdk/core/src/typechain-types/index.ts | 6 + sdk/core/src/types/types.ts | 5 + yarn.lock | 20 +- 17 files changed, 4836 insertions(+), 252 deletions(-) create mode 100644 sdk/core/app/contracts/IdentityVerificationHubImpl.ts create mode 100644 sdk/core/app/contracts/common.ts create mode 100644 sdk/core/app/contracts/factories/IdentityVerificationHubImpl__factory.ts create mode 100644 sdk/core/app/contracts/factories/index.ts create mode 100644 sdk/core/app/contracts/index.ts create mode 100644 sdk/core/scripts/fix-imports.js create mode 100644 sdk/core/src/abi/IdentityVerificationHubImpl.json create mode 100644 sdk/core/src/typechain-types/IdentityVerificationHubImpl.ts create mode 100644 sdk/core/src/typechain-types/common.ts create mode 100644 sdk/core/src/typechain-types/factories/IdentityVerificationHubImpl__factory.ts create mode 100644 sdk/core/src/typechain-types/factories/index.ts create mode 100644 sdk/core/src/typechain-types/index.ts diff --git a/sdk/core/app/contracts/IdentityVerificationHubImpl.ts b/sdk/core/app/contracts/IdentityVerificationHubImpl.ts new file mode 100644 index 000000000..b4cf49f46 --- /dev/null +++ b/sdk/core/app/contracts/IdentityVerificationHubImpl.ts @@ -0,0 +1,886 @@ +/* Autogenerated file. Do not edit manually. */ +/* tslint:disable */ +/* eslint-disable */ +import type { + BaseContract, + BigNumberish, + BytesLike, + FunctionFragment, + Result, + Interface, + EventFragment, + AddressLike, + ContractRunner, + ContractMethod, + Listener, +} from "ethers"; +import type { + TypedContractEvent, + TypedDeferredTopicFilter, + TypedEventLog, + TypedLogDescription, + TypedListener, + TypedContractMethod, +} from "./common"; + +export declare namespace IRegisterCircuitVerifier { + export type RegisterCircuitProofStruct = { + a: [BigNumberish, BigNumberish]; + b: [[BigNumberish, BigNumberish], [BigNumberish, BigNumberish]]; + c: [BigNumberish, BigNumberish]; + pubSignals: [BigNumberish, BigNumberish, BigNumberish]; + }; + + export type RegisterCircuitProofStructOutput = [ + a: [bigint, bigint], + b: [[bigint, bigint], [bigint, bigint]], + c: [bigint, bigint], + pubSignals: [bigint, bigint, bigint] + ] & { + a: [bigint, bigint]; + b: [[bigint, bigint], [bigint, bigint]]; + c: [bigint, bigint]; + pubSignals: [bigint, bigint, bigint]; + }; +} + +export declare namespace IDscCircuitVerifier { + export type DscCircuitProofStruct = { + a: [BigNumberish, BigNumberish]; + b: [[BigNumberish, BigNumberish], [BigNumberish, BigNumberish]]; + c: [BigNumberish, BigNumberish]; + pubSignals: [BigNumberish, BigNumberish]; + }; + + export type DscCircuitProofStructOutput = [ + a: [bigint, bigint], + b: [[bigint, bigint], [bigint, bigint]], + c: [bigint, bigint], + pubSignals: [bigint, bigint] + ] & { + a: [bigint, bigint]; + b: [[bigint, bigint], [bigint, bigint]]; + c: [bigint, bigint]; + pubSignals: [bigint, bigint]; + }; +} + +export interface IdentityVerificationHubImplInterface extends Interface { + getFunction( + nameOrSignature: + | "UPGRADE_INTERFACE_VERSION" + | "acceptOwnership" + | "batchUpdateDscCircuitVerifiers" + | "batchUpdateRegisterCircuitVerifiers" + | "initialize" + | "owner" + | "pendingOwner" + | "proxiableUUID" + | "registerCommitment" + | "registerDscKeyCommitment" + | "registry" + | "renounceOwnership" + | "sigTypeToDscCircuitVerifiers" + | "sigTypeToRegisterCircuitVerifiers" + | "transferOwnership" + | "updateDscVerifier" + | "updateRegisterCircuitVerifier" + | "updateRegistry" + | "updateVcAndDiscloseCircuit" + | "upgradeToAndCall" + | "vcAndDiscloseCircuitVerifier" + | "verifyVcAndDisclose" + ): FunctionFragment; + + getEvent( + nameOrSignatureOrTopic: + | "DscCircuitVerifierUpdated" + | "HubInitialized" + | "Initialized" + | "OwnershipTransferStarted" + | "OwnershipTransferred" + | "RegisterCircuitVerifierUpdated" + | "RegistryUpdated" + | "Upgraded" + | "VcAndDiscloseCircuitUpdated" + ): EventFragment; + + encodeFunctionData( + functionFragment: "UPGRADE_INTERFACE_VERSION", + values?: undefined + ): string; + encodeFunctionData( + functionFragment: "acceptOwnership", + values?: undefined + ): string; + encodeFunctionData( + functionFragment: "batchUpdateDscCircuitVerifiers", + values: [BigNumberish[], AddressLike[]] + ): string; + encodeFunctionData( + functionFragment: "batchUpdateRegisterCircuitVerifiers", + values: [BigNumberish[], AddressLike[]] + ): string; + encodeFunctionData( + functionFragment: "initialize", + values: [ + BytesLike[], + AddressLike[], + AddressLike[], + BigNumberish[], + AddressLike[], + BigNumberish[], + AddressLike[] + ] + ): string; + encodeFunctionData(functionFragment: "owner", values?: undefined): string; + encodeFunctionData( + functionFragment: "pendingOwner", + values?: undefined + ): string; + encodeFunctionData( + functionFragment: "proxiableUUID", + values?: undefined + ): string; + encodeFunctionData( + functionFragment: "registerCommitment", + values: [ + BytesLike, + BigNumberish, + IRegisterCircuitVerifier.RegisterCircuitProofStruct + ] + ): string; + encodeFunctionData( + functionFragment: "registerDscKeyCommitment", + values: [BytesLike, BigNumberish, IDscCircuitVerifier.DscCircuitProofStruct] + ): string; + encodeFunctionData(functionFragment: "registry", values: [BytesLike]): string; + encodeFunctionData( + functionFragment: "renounceOwnership", + values?: undefined + ): string; + encodeFunctionData( + functionFragment: "sigTypeToDscCircuitVerifiers", + values: [BigNumberish] + ): string; + encodeFunctionData( + functionFragment: "sigTypeToRegisterCircuitVerifiers", + values: [BigNumberish] + ): string; + encodeFunctionData( + functionFragment: "transferOwnership", + values: [AddressLike] + ): string; + encodeFunctionData( + functionFragment: "updateDscVerifier", + values: [BigNumberish, AddressLike] + ): string; + encodeFunctionData( + functionFragment: "updateRegisterCircuitVerifier", + values: [BigNumberish, AddressLike] + ): string; + encodeFunctionData( + functionFragment: "updateRegistry", + values: [BytesLike, AddressLike] + ): string; + encodeFunctionData( + functionFragment: "updateVcAndDiscloseCircuit", + values: [BytesLike, AddressLike] + ): string; + encodeFunctionData( + functionFragment: "upgradeToAndCall", + values: [AddressLike, BytesLike] + ): string; + encodeFunctionData( + functionFragment: "vcAndDiscloseCircuitVerifier", + values: [BytesLike] + ): string; + encodeFunctionData( + functionFragment: "verifyVcAndDisclose", + values: [BytesLike] + ): string; + + decodeFunctionResult( + functionFragment: "UPGRADE_INTERFACE_VERSION", + data: BytesLike + ): Result; + decodeFunctionResult( + functionFragment: "acceptOwnership", + data: BytesLike + ): Result; + decodeFunctionResult( + functionFragment: "batchUpdateDscCircuitVerifiers", + data: BytesLike + ): Result; + decodeFunctionResult( + functionFragment: "batchUpdateRegisterCircuitVerifiers", + data: BytesLike + ): Result; + decodeFunctionResult(functionFragment: "initialize", data: BytesLike): Result; + decodeFunctionResult(functionFragment: "owner", data: BytesLike): Result; + decodeFunctionResult( + functionFragment: "pendingOwner", + data: BytesLike + ): Result; + decodeFunctionResult( + functionFragment: "proxiableUUID", + data: BytesLike + ): Result; + decodeFunctionResult( + functionFragment: "registerCommitment", + data: BytesLike + ): Result; + decodeFunctionResult( + functionFragment: "registerDscKeyCommitment", + data: BytesLike + ): Result; + decodeFunctionResult(functionFragment: "registry", data: BytesLike): Result; + decodeFunctionResult( + functionFragment: "renounceOwnership", + data: BytesLike + ): Result; + decodeFunctionResult( + functionFragment: "sigTypeToDscCircuitVerifiers", + data: BytesLike + ): Result; + decodeFunctionResult( + functionFragment: "sigTypeToRegisterCircuitVerifiers", + data: BytesLike + ): Result; + decodeFunctionResult( + functionFragment: "transferOwnership", + data: BytesLike + ): Result; + decodeFunctionResult( + functionFragment: "updateDscVerifier", + data: BytesLike + ): Result; + decodeFunctionResult( + functionFragment: "updateRegisterCircuitVerifier", + data: BytesLike + ): Result; + decodeFunctionResult( + functionFragment: "updateRegistry", + data: BytesLike + ): Result; + decodeFunctionResult( + functionFragment: "updateVcAndDiscloseCircuit", + data: BytesLike + ): Result; + decodeFunctionResult( + functionFragment: "upgradeToAndCall", + data: BytesLike + ): Result; + decodeFunctionResult( + functionFragment: "vcAndDiscloseCircuitVerifier", + data: BytesLike + ): Result; + decodeFunctionResult( + functionFragment: "verifyVcAndDisclose", + data: BytesLike + ): Result; +} + +export namespace DscCircuitVerifierUpdatedEvent { + export type InputTuple = [typeId: BigNumberish, verifier: AddressLike]; + export type OutputTuple = [typeId: bigint, verifier: string]; + export interface OutputObject { + typeId: bigint; + verifier: string; + } + export type Event = TypedContractEvent; + export type Filter = TypedDeferredTopicFilter; + export type Log = TypedEventLog; + export type LogDescription = TypedLogDescription; +} + +export namespace HubInitializedEvent { + export type InputTuple = [ + attestationIds: BytesLike[], + registryAddresses: AddressLike[], + vcAndDiscloseCircuitVerifiers: AddressLike[], + registerCircuitVerifierIds: BigNumberish[], + registerCircuitVerifiers: AddressLike[], + dscCircuitVerifierIds: BigNumberish[], + dscCircuitVerifiers: AddressLike[] + ]; + export type OutputTuple = [ + attestationIds: string[], + registryAddresses: string[], + vcAndDiscloseCircuitVerifiers: string[], + registerCircuitVerifierIds: bigint[], + registerCircuitVerifiers: string[], + dscCircuitVerifierIds: bigint[], + dscCircuitVerifiers: string[] + ]; + export interface OutputObject { + attestationIds: string[]; + registryAddresses: string[]; + vcAndDiscloseCircuitVerifiers: string[]; + registerCircuitVerifierIds: bigint[]; + registerCircuitVerifiers: string[]; + dscCircuitVerifierIds: bigint[]; + dscCircuitVerifiers: string[]; + } + export type Event = TypedContractEvent; + export type Filter = TypedDeferredTopicFilter; + export type Log = TypedEventLog; + export type LogDescription = TypedLogDescription; +} + +export namespace InitializedEvent { + export type InputTuple = [version: BigNumberish]; + export type OutputTuple = [version: bigint]; + export interface OutputObject { + version: bigint; + } + export type Event = TypedContractEvent; + export type Filter = TypedDeferredTopicFilter; + export type Log = TypedEventLog; + export type LogDescription = TypedLogDescription; +} + +export namespace OwnershipTransferStartedEvent { + export type InputTuple = [previousOwner: AddressLike, newOwner: AddressLike]; + export type OutputTuple = [previousOwner: string, newOwner: string]; + export interface OutputObject { + previousOwner: string; + newOwner: string; + } + export type Event = TypedContractEvent; + export type Filter = TypedDeferredTopicFilter; + export type Log = TypedEventLog; + export type LogDescription = TypedLogDescription; +} + +export namespace OwnershipTransferredEvent { + export type InputTuple = [previousOwner: AddressLike, newOwner: AddressLike]; + export type OutputTuple = [previousOwner: string, newOwner: string]; + export interface OutputObject { + previousOwner: string; + newOwner: string; + } + export type Event = TypedContractEvent; + export type Filter = TypedDeferredTopicFilter; + export type Log = TypedEventLog; + export type LogDescription = TypedLogDescription; +} + +export namespace RegisterCircuitVerifierUpdatedEvent { + export type InputTuple = [typeId: BigNumberish, verifier: AddressLike]; + export type OutputTuple = [typeId: bigint, verifier: string]; + export interface OutputObject { + typeId: bigint; + verifier: string; + } + export type Event = TypedContractEvent; + export type Filter = TypedDeferredTopicFilter; + export type Log = TypedEventLog; + export type LogDescription = TypedLogDescription; +} + +export namespace RegistryUpdatedEvent { + export type InputTuple = [attestationId: BytesLike, registry: AddressLike]; + export type OutputTuple = [attestationId: string, registry: string]; + export interface OutputObject { + attestationId: string; + registry: string; + } + export type Event = TypedContractEvent; + export type Filter = TypedDeferredTopicFilter; + export type Log = TypedEventLog; + export type LogDescription = TypedLogDescription; +} + +export namespace UpgradedEvent { + export type InputTuple = [implementation: AddressLike]; + export type OutputTuple = [implementation: string]; + export interface OutputObject { + implementation: string; + } + export type Event = TypedContractEvent; + export type Filter = TypedDeferredTopicFilter; + export type Log = TypedEventLog; + export type LogDescription = TypedLogDescription; +} + +export namespace VcAndDiscloseCircuitUpdatedEvent { + export type InputTuple = [ + attestationId: BytesLike, + vcAndDiscloseCircuitVerifier: AddressLike + ]; + export type OutputTuple = [ + attestationId: string, + vcAndDiscloseCircuitVerifier: string + ]; + export interface OutputObject { + attestationId: string; + vcAndDiscloseCircuitVerifier: string; + } + export type Event = TypedContractEvent; + export type Filter = TypedDeferredTopicFilter; + export type Log = TypedEventLog; + export type LogDescription = TypedLogDescription; +} + +export interface IdentityVerificationHubImpl extends BaseContract { + connect(runner?: ContractRunner | null): IdentityVerificationHubImpl; + waitForDeployment(): Promise; + + interface: IdentityVerificationHubImplInterface; + + queryFilter( + event: TCEvent, + fromBlockOrBlockhash?: string | number | undefined, + toBlock?: string | number | undefined + ): Promise>>; + queryFilter( + filter: TypedDeferredTopicFilter, + fromBlockOrBlockhash?: string | number | undefined, + toBlock?: string | number | undefined + ): Promise>>; + + on( + event: TCEvent, + listener: TypedListener + ): Promise; + on( + filter: TypedDeferredTopicFilter, + listener: TypedListener + ): Promise; + + once( + event: TCEvent, + listener: TypedListener + ): Promise; + once( + filter: TypedDeferredTopicFilter, + listener: TypedListener + ): Promise; + + listeners( + event: TCEvent + ): Promise>>; + listeners(eventName?: string): Promise>; + removeAllListeners( + event?: TCEvent + ): Promise; + + UPGRADE_INTERFACE_VERSION: TypedContractMethod<[], [string], "view">; + + acceptOwnership: TypedContractMethod<[], [void], "nonpayable">; + + batchUpdateDscCircuitVerifiers: TypedContractMethod< + [typeIds: BigNumberish[], verifierAddresses: AddressLike[]], + [void], + "nonpayable" + >; + + batchUpdateRegisterCircuitVerifiers: TypedContractMethod< + [typeIds: BigNumberish[], verifierAddresses: AddressLike[]], + [void], + "nonpayable" + >; + + initialize: TypedContractMethod< + [ + attestationIds: BytesLike[], + registryAddresses: AddressLike[], + vcAndDiscloseCircuitVerifierAddresses: AddressLike[], + registerCircuitVerifierIds: BigNumberish[], + registerCircuitVerifierAddresses: AddressLike[], + dscCircuitVerifierIds: BigNumberish[], + dscCircuitVerifierAddresses: AddressLike[] + ], + [void], + "nonpayable" + >; + + owner: TypedContractMethod<[], [string], "view">; + + pendingOwner: TypedContractMethod<[], [string], "view">; + + proxiableUUID: TypedContractMethod<[], [string], "view">; + + registerCommitment: TypedContractMethod< + [ + attestationId: BytesLike, + registerCircuitVerifierId: BigNumberish, + registerCircuitProof: IRegisterCircuitVerifier.RegisterCircuitProofStruct + ], + [void], + "nonpayable" + >; + + registerDscKeyCommitment: TypedContractMethod< + [ + attestationId: BytesLike, + dscCircuitVerifierId: BigNumberish, + dscCircuitProof: IDscCircuitVerifier.DscCircuitProofStruct + ], + [void], + "nonpayable" + >; + + registry: TypedContractMethod<[attestationId: BytesLike], [string], "view">; + + renounceOwnership: TypedContractMethod<[], [void], "nonpayable">; + + sigTypeToDscCircuitVerifiers: TypedContractMethod< + [typeId: BigNumberish], + [string], + "view" + >; + + sigTypeToRegisterCircuitVerifiers: TypedContractMethod< + [typeId: BigNumberish], + [string], + "view" + >; + + transferOwnership: TypedContractMethod< + [newOwner: AddressLike], + [void], + "nonpayable" + >; + + updateDscVerifier: TypedContractMethod< + [typeId: BigNumberish, verifierAddress: AddressLike], + [void], + "nonpayable" + >; + + updateRegisterCircuitVerifier: TypedContractMethod< + [typeId: BigNumberish, verifierAddress: AddressLike], + [void], + "nonpayable" + >; + + updateRegistry: TypedContractMethod< + [attestationId: BytesLike, registryAddress: AddressLike], + [void], + "nonpayable" + >; + + updateVcAndDiscloseCircuit: TypedContractMethod< + [ + attestationId: BytesLike, + vcAndDiscloseCircuitVerifierAddress: AddressLike + ], + [void], + "nonpayable" + >; + + upgradeToAndCall: TypedContractMethod< + [newImplementation: AddressLike, data: BytesLike], + [void], + "payable" + >; + + vcAndDiscloseCircuitVerifier: TypedContractMethod< + [attestationId: BytesLike], + [string], + "view" + >; + + verifyVcAndDisclose: TypedContractMethod< + [proofData: BytesLike], + [string], + "view" + >; + + getFunction( + key: string | FunctionFragment + ): T; + + getFunction( + nameOrSignature: "UPGRADE_INTERFACE_VERSION" + ): TypedContractMethod<[], [string], "view">; + getFunction( + nameOrSignature: "acceptOwnership" + ): TypedContractMethod<[], [void], "nonpayable">; + getFunction( + nameOrSignature: "batchUpdateDscCircuitVerifiers" + ): TypedContractMethod< + [typeIds: BigNumberish[], verifierAddresses: AddressLike[]], + [void], + "nonpayable" + >; + getFunction( + nameOrSignature: "batchUpdateRegisterCircuitVerifiers" + ): TypedContractMethod< + [typeIds: BigNumberish[], verifierAddresses: AddressLike[]], + [void], + "nonpayable" + >; + getFunction( + nameOrSignature: "initialize" + ): TypedContractMethod< + [ + attestationIds: BytesLike[], + registryAddresses: AddressLike[], + vcAndDiscloseCircuitVerifierAddresses: AddressLike[], + registerCircuitVerifierIds: BigNumberish[], + registerCircuitVerifierAddresses: AddressLike[], + dscCircuitVerifierIds: BigNumberish[], + dscCircuitVerifierAddresses: AddressLike[] + ], + [void], + "nonpayable" + >; + getFunction( + nameOrSignature: "owner" + ): TypedContractMethod<[], [string], "view">; + getFunction( + nameOrSignature: "pendingOwner" + ): TypedContractMethod<[], [string], "view">; + getFunction( + nameOrSignature: "proxiableUUID" + ): TypedContractMethod<[], [string], "view">; + getFunction( + nameOrSignature: "registerCommitment" + ): TypedContractMethod< + [ + attestationId: BytesLike, + registerCircuitVerifierId: BigNumberish, + registerCircuitProof: IRegisterCircuitVerifier.RegisterCircuitProofStruct + ], + [void], + "nonpayable" + >; + getFunction( + nameOrSignature: "registerDscKeyCommitment" + ): TypedContractMethod< + [ + attestationId: BytesLike, + dscCircuitVerifierId: BigNumberish, + dscCircuitProof: IDscCircuitVerifier.DscCircuitProofStruct + ], + [void], + "nonpayable" + >; + getFunction( + nameOrSignature: "registry" + ): TypedContractMethod<[attestationId: BytesLike], [string], "view">; + getFunction( + nameOrSignature: "renounceOwnership" + ): TypedContractMethod<[], [void], "nonpayable">; + getFunction( + nameOrSignature: "sigTypeToDscCircuitVerifiers" + ): TypedContractMethod<[typeId: BigNumberish], [string], "view">; + getFunction( + nameOrSignature: "sigTypeToRegisterCircuitVerifiers" + ): TypedContractMethod<[typeId: BigNumberish], [string], "view">; + getFunction( + nameOrSignature: "transferOwnership" + ): TypedContractMethod<[newOwner: AddressLike], [void], "nonpayable">; + getFunction( + nameOrSignature: "updateDscVerifier" + ): TypedContractMethod< + [typeId: BigNumberish, verifierAddress: AddressLike], + [void], + "nonpayable" + >; + getFunction( + nameOrSignature: "updateRegisterCircuitVerifier" + ): TypedContractMethod< + [typeId: BigNumberish, verifierAddress: AddressLike], + [void], + "nonpayable" + >; + getFunction( + nameOrSignature: "updateRegistry" + ): TypedContractMethod< + [attestationId: BytesLike, registryAddress: AddressLike], + [void], + "nonpayable" + >; + getFunction( + nameOrSignature: "updateVcAndDiscloseCircuit" + ): TypedContractMethod< + [ + attestationId: BytesLike, + vcAndDiscloseCircuitVerifierAddress: AddressLike + ], + [void], + "nonpayable" + >; + getFunction( + nameOrSignature: "upgradeToAndCall" + ): TypedContractMethod< + [newImplementation: AddressLike, data: BytesLike], + [void], + "payable" + >; + getFunction( + nameOrSignature: "vcAndDiscloseCircuitVerifier" + ): TypedContractMethod<[attestationId: BytesLike], [string], "view">; + getFunction( + nameOrSignature: "verifyVcAndDisclose" + ): TypedContractMethod<[proofData: BytesLike], [string], "view">; + + getEvent( + key: "DscCircuitVerifierUpdated" + ): TypedContractEvent< + DscCircuitVerifierUpdatedEvent.InputTuple, + DscCircuitVerifierUpdatedEvent.OutputTuple, + DscCircuitVerifierUpdatedEvent.OutputObject + >; + getEvent( + key: "HubInitialized" + ): TypedContractEvent< + HubInitializedEvent.InputTuple, + HubInitializedEvent.OutputTuple, + HubInitializedEvent.OutputObject + >; + getEvent( + key: "Initialized" + ): TypedContractEvent< + InitializedEvent.InputTuple, + InitializedEvent.OutputTuple, + InitializedEvent.OutputObject + >; + getEvent( + key: "OwnershipTransferStarted" + ): TypedContractEvent< + OwnershipTransferStartedEvent.InputTuple, + OwnershipTransferStartedEvent.OutputTuple, + OwnershipTransferStartedEvent.OutputObject + >; + getEvent( + key: "OwnershipTransferred" + ): TypedContractEvent< + OwnershipTransferredEvent.InputTuple, + OwnershipTransferredEvent.OutputTuple, + OwnershipTransferredEvent.OutputObject + >; + getEvent( + key: "RegisterCircuitVerifierUpdated" + ): TypedContractEvent< + RegisterCircuitVerifierUpdatedEvent.InputTuple, + RegisterCircuitVerifierUpdatedEvent.OutputTuple, + RegisterCircuitVerifierUpdatedEvent.OutputObject + >; + getEvent( + key: "RegistryUpdated" + ): TypedContractEvent< + RegistryUpdatedEvent.InputTuple, + RegistryUpdatedEvent.OutputTuple, + RegistryUpdatedEvent.OutputObject + >; + getEvent( + key: "Upgraded" + ): TypedContractEvent< + UpgradedEvent.InputTuple, + UpgradedEvent.OutputTuple, + UpgradedEvent.OutputObject + >; + getEvent( + key: "VcAndDiscloseCircuitUpdated" + ): TypedContractEvent< + VcAndDiscloseCircuitUpdatedEvent.InputTuple, + VcAndDiscloseCircuitUpdatedEvent.OutputTuple, + VcAndDiscloseCircuitUpdatedEvent.OutputObject + >; + + filters: { + "DscCircuitVerifierUpdated(uint256,address)": TypedContractEvent< + DscCircuitVerifierUpdatedEvent.InputTuple, + DscCircuitVerifierUpdatedEvent.OutputTuple, + DscCircuitVerifierUpdatedEvent.OutputObject + >; + DscCircuitVerifierUpdated: TypedContractEvent< + DscCircuitVerifierUpdatedEvent.InputTuple, + DscCircuitVerifierUpdatedEvent.OutputTuple, + DscCircuitVerifierUpdatedEvent.OutputObject + >; + + "HubInitialized(bytes32[],address[],address[],uint256[],address[],uint256[],address[])": TypedContractEvent< + HubInitializedEvent.InputTuple, + HubInitializedEvent.OutputTuple, + HubInitializedEvent.OutputObject + >; + HubInitialized: TypedContractEvent< + HubInitializedEvent.InputTuple, + HubInitializedEvent.OutputTuple, + HubInitializedEvent.OutputObject + >; + + "Initialized(uint64)": TypedContractEvent< + InitializedEvent.InputTuple, + InitializedEvent.OutputTuple, + InitializedEvent.OutputObject + >; + Initialized: TypedContractEvent< + InitializedEvent.InputTuple, + InitializedEvent.OutputTuple, + InitializedEvent.OutputObject + >; + + "OwnershipTransferStarted(address,address)": TypedContractEvent< + OwnershipTransferStartedEvent.InputTuple, + OwnershipTransferStartedEvent.OutputTuple, + OwnershipTransferStartedEvent.OutputObject + >; + OwnershipTransferStarted: TypedContractEvent< + OwnershipTransferStartedEvent.InputTuple, + OwnershipTransferStartedEvent.OutputTuple, + OwnershipTransferStartedEvent.OutputObject + >; + + "OwnershipTransferred(address,address)": TypedContractEvent< + OwnershipTransferredEvent.InputTuple, + OwnershipTransferredEvent.OutputTuple, + OwnershipTransferredEvent.OutputObject + >; + OwnershipTransferred: TypedContractEvent< + OwnershipTransferredEvent.InputTuple, + OwnershipTransferredEvent.OutputTuple, + OwnershipTransferredEvent.OutputObject + >; + + "RegisterCircuitVerifierUpdated(uint256,address)": TypedContractEvent< + RegisterCircuitVerifierUpdatedEvent.InputTuple, + RegisterCircuitVerifierUpdatedEvent.OutputTuple, + RegisterCircuitVerifierUpdatedEvent.OutputObject + >; + RegisterCircuitVerifierUpdated: TypedContractEvent< + RegisterCircuitVerifierUpdatedEvent.InputTuple, + RegisterCircuitVerifierUpdatedEvent.OutputTuple, + RegisterCircuitVerifierUpdatedEvent.OutputObject + >; + + "RegistryUpdated(bytes32,address)": TypedContractEvent< + RegistryUpdatedEvent.InputTuple, + RegistryUpdatedEvent.OutputTuple, + RegistryUpdatedEvent.OutputObject + >; + RegistryUpdated: TypedContractEvent< + RegistryUpdatedEvent.InputTuple, + RegistryUpdatedEvent.OutputTuple, + RegistryUpdatedEvent.OutputObject + >; + + "Upgraded(address)": TypedContractEvent< + UpgradedEvent.InputTuple, + UpgradedEvent.OutputTuple, + UpgradedEvent.OutputObject + >; + Upgraded: TypedContractEvent< + UpgradedEvent.InputTuple, + UpgradedEvent.OutputTuple, + UpgradedEvent.OutputObject + >; + + "VcAndDiscloseCircuitUpdated(bytes32,address)": TypedContractEvent< + VcAndDiscloseCircuitUpdatedEvent.InputTuple, + VcAndDiscloseCircuitUpdatedEvent.OutputTuple, + VcAndDiscloseCircuitUpdatedEvent.OutputObject + >; + VcAndDiscloseCircuitUpdated: TypedContractEvent< + VcAndDiscloseCircuitUpdatedEvent.InputTuple, + VcAndDiscloseCircuitUpdatedEvent.OutputTuple, + VcAndDiscloseCircuitUpdatedEvent.OutputObject + >; + }; +} diff --git a/sdk/core/app/contracts/common.ts b/sdk/core/app/contracts/common.ts new file mode 100644 index 000000000..56b5f21e9 --- /dev/null +++ b/sdk/core/app/contracts/common.ts @@ -0,0 +1,131 @@ +/* Autogenerated file. Do not edit manually. */ +/* tslint:disable */ +/* eslint-disable */ +import type { + FunctionFragment, + Typed, + EventFragment, + ContractTransaction, + ContractTransactionResponse, + DeferredTopicFilter, + EventLog, + TransactionRequest, + LogDescription, +} from "ethers"; + +export interface TypedDeferredTopicFilter<_TCEvent extends TypedContractEvent> + extends DeferredTopicFilter {} + +export interface TypedContractEvent< + InputTuple extends Array = any, + OutputTuple extends Array = any, + OutputObject = any +> { + (...args: Partial): TypedDeferredTopicFilter< + TypedContractEvent + >; + name: string; + fragment: EventFragment; + getFragment(...args: Partial): EventFragment; +} + +type __TypechainAOutputTuple = T extends TypedContractEvent< + infer _U, + infer W +> + ? W + : never; +type __TypechainOutputObject = T extends TypedContractEvent< + infer _U, + infer _W, + infer V +> + ? V + : never; + +export interface TypedEventLog + extends Omit { + args: __TypechainAOutputTuple & __TypechainOutputObject; +} + +export interface TypedLogDescription + extends Omit { + args: __TypechainAOutputTuple & __TypechainOutputObject; +} + +export type TypedListener = ( + ...listenerArg: [ + ...__TypechainAOutputTuple, + TypedEventLog, + ...undefined[] + ] +) => void; + +export type MinEthersFactory = { + deploy(...a: ARGS[]): Promise; +}; + +export type GetContractTypeFromFactory = F extends MinEthersFactory< + infer C, + any +> + ? C + : never; +export type GetARGsTypeFromFactory = F extends MinEthersFactory + ? Parameters + : never; + +export type StateMutability = "nonpayable" | "payable" | "view"; + +export type BaseOverrides = Omit; +export type NonPayableOverrides = Omit< + BaseOverrides, + "value" | "blockTag" | "enableCcipRead" +>; +export type PayableOverrides = Omit< + BaseOverrides, + "blockTag" | "enableCcipRead" +>; +export type ViewOverrides = Omit; +export type Overrides = S extends "nonpayable" + ? NonPayableOverrides + : S extends "payable" + ? PayableOverrides + : ViewOverrides; + +export type PostfixOverrides, S extends StateMutability> = + | A + | [...A, Overrides]; +export type ContractMethodArgs< + A extends Array, + S extends StateMutability +> = PostfixOverrides<{ [I in keyof A]-?: A[I] | Typed }, S>; + +export type DefaultReturnType = R extends Array ? R[0] : R; + +// export interface ContractMethod = Array, R = any, D extends R | ContractTransactionResponse = R | ContractTransactionResponse> { +export interface TypedContractMethod< + A extends Array = Array, + R = any, + S extends StateMutability = "payable" +> { + (...args: ContractMethodArgs): S extends "view" + ? Promise> + : Promise; + + name: string; + + fragment: FunctionFragment; + + getFragment(...args: ContractMethodArgs): FunctionFragment; + + populateTransaction( + ...args: ContractMethodArgs + ): Promise; + staticCall( + ...args: ContractMethodArgs + ): Promise>; + send(...args: ContractMethodArgs): Promise; + estimateGas(...args: ContractMethodArgs): Promise; + staticCallResult(...args: ContractMethodArgs): Promise; +} diff --git a/sdk/core/app/contracts/factories/IdentityVerificationHubImpl__factory.ts b/sdk/core/app/contracts/factories/IdentityVerificationHubImpl__factory.ts new file mode 100644 index 000000000..72fb2f01a --- /dev/null +++ b/sdk/core/app/contracts/factories/IdentityVerificationHubImpl__factory.ts @@ -0,0 +1,836 @@ +/* Autogenerated file. Do not edit manually. */ +/* tslint:disable */ +/* eslint-disable */ + +import { Contract, Interface, type ContractRunner } from "ethers"; +import type { + IdentityVerificationHubImpl, + IdentityVerificationHubImplInterface, +} from "../IdentityVerificationHubImpl"; + +const _abi = [ + { + inputs: [], + stateMutability: "nonpayable", + type: "constructor", + }, + { + inputs: [ + { + internalType: "address", + name: "target", + type: "address", + }, + ], + name: "AddressEmptyCode", + type: "error", + }, + { + inputs: [], + name: "CURRENT_DATE_NOT_IN_VALID_RANGE", + type: "error", + }, + { + inputs: [ + { + internalType: "address", + name: "implementation", + type: "address", + }, + ], + name: "ERC1967InvalidImplementation", + type: "error", + }, + { + inputs: [], + name: "ERC1967NonPayable", + type: "error", + }, + { + inputs: [], + name: "FailedCall", + type: "error", + }, + { + inputs: [], + name: "INVALID_ATTESTATION_ID", + type: "error", + }, + { + inputs: [], + name: "INVALID_COMMITMENT_ROOT", + type: "error", + }, + { + inputs: [], + name: "INVALID_CSCA_ROOT", + type: "error", + }, + { + inputs: [], + name: "INVALID_DSC_PROOF", + type: "error", + }, + { + inputs: [], + name: "INVALID_FORBIDDEN_COUNTRIES", + type: "error", + }, + { + inputs: [], + name: "INVALID_OFAC", + type: "error", + }, + { + inputs: [], + name: "INVALID_OFAC_ROOT", + type: "error", + }, + { + inputs: [], + name: "INVALID_OLDER_THAN", + type: "error", + }, + { + inputs: [], + name: "INVALID_REGISTER_PROOF", + type: "error", + }, + { + inputs: [], + name: "INVALID_REVEALED_DATA_TYPE", + type: "error", + }, + { + inputs: [], + name: "INVALID_VC_AND_DISCLOSE_PROOF", + type: "error", + }, + { + inputs: [], + name: "InvalidDateDigit", + type: "error", + }, + { + inputs: [], + name: "InvalidDateLength", + type: "error", + }, + { + inputs: [], + name: "InvalidDayRange", + type: "error", + }, + { + inputs: [], + name: "InvalidFieldElement", + type: "error", + }, + { + inputs: [], + name: "InvalidInitialization", + type: "error", + }, + { + inputs: [], + name: "InvalidMonthRange", + type: "error", + }, + { + inputs: [], + name: "InvalidYearRange", + type: "error", + }, + { + inputs: [], + name: "LENGTH_MISMATCH", + type: "error", + }, + { + inputs: [], + name: "NO_VERIFIER_SET", + type: "error", + }, + { + inputs: [], + name: "NotInitializing", + type: "error", + }, + { + inputs: [ + { + internalType: "address", + name: "owner", + type: "address", + }, + ], + name: "OwnableInvalidOwner", + type: "error", + }, + { + inputs: [ + { + internalType: "address", + name: "account", + type: "address", + }, + ], + name: "OwnableUnauthorizedAccount", + type: "error", + }, + { + inputs: [], + name: "UUPSUnauthorizedCallContext", + type: "error", + }, + { + inputs: [ + { + internalType: "bytes32", + name: "slot", + type: "bytes32", + }, + ], + name: "UUPSUnsupportedProxiableUUID", + type: "error", + }, + { + anonymous: false, + inputs: [ + { + indexed: false, + internalType: "uint256", + name: "typeId", + type: "uint256", + }, + { + indexed: false, + internalType: "address", + name: "verifier", + type: "address", + }, + ], + name: "DscCircuitVerifierUpdated", + type: "event", + }, + { + anonymous: false, + inputs: [ + { + indexed: false, + internalType: "bytes32[]", + name: "attestationIds", + type: "bytes32[]", + }, + { + indexed: false, + internalType: "address[]", + name: "registryAddresses", + type: "address[]", + }, + { + indexed: false, + internalType: "address[]", + name: "vcAndDiscloseCircuitVerifiers", + type: "address[]", + }, + { + indexed: false, + internalType: "uint256[]", + name: "registerCircuitVerifierIds", + type: "uint256[]", + }, + { + indexed: false, + internalType: "address[]", + name: "registerCircuitVerifiers", + type: "address[]", + }, + { + indexed: false, + internalType: "uint256[]", + name: "dscCircuitVerifierIds", + type: "uint256[]", + }, + { + indexed: false, + internalType: "address[]", + name: "dscCircuitVerifiers", + type: "address[]", + }, + ], + name: "HubInitialized", + type: "event", + }, + { + anonymous: false, + inputs: [ + { + indexed: false, + internalType: "uint64", + name: "version", + type: "uint64", + }, + ], + name: "Initialized", + type: "event", + }, + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: "address", + name: "previousOwner", + type: "address", + }, + { + indexed: true, + internalType: "address", + name: "newOwner", + type: "address", + }, + ], + name: "OwnershipTransferStarted", + type: "event", + }, + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: "address", + name: "previousOwner", + type: "address", + }, + { + indexed: true, + internalType: "address", + name: "newOwner", + type: "address", + }, + ], + name: "OwnershipTransferred", + type: "event", + }, + { + anonymous: false, + inputs: [ + { + indexed: false, + internalType: "uint256", + name: "typeId", + type: "uint256", + }, + { + indexed: false, + internalType: "address", + name: "verifier", + type: "address", + }, + ], + name: "RegisterCircuitVerifierUpdated", + type: "event", + }, + { + anonymous: false, + inputs: [ + { + indexed: false, + internalType: "bytes32", + name: "attestationId", + type: "bytes32", + }, + { + indexed: false, + internalType: "address", + name: "registry", + type: "address", + }, + ], + name: "RegistryUpdated", + type: "event", + }, + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: "address", + name: "implementation", + type: "address", + }, + ], + name: "Upgraded", + type: "event", + }, + { + anonymous: false, + inputs: [ + { + indexed: false, + internalType: "bytes32", + name: "attestationId", + type: "bytes32", + }, + { + indexed: false, + internalType: "address", + name: "vcAndDiscloseCircuitVerifier", + type: "address", + }, + ], + name: "VcAndDiscloseCircuitUpdated", + type: "event", + }, + { + inputs: [], + name: "UPGRADE_INTERFACE_VERSION", + outputs: [ + { + internalType: "string", + name: "", + type: "string", + }, + ], + stateMutability: "view", + type: "function", + }, + { + inputs: [], + name: "acceptOwnership", + outputs: [], + stateMutability: "nonpayable", + type: "function", + }, + { + inputs: [ + { + internalType: "uint256[]", + name: "typeIds", + type: "uint256[]", + }, + { + internalType: "address[]", + name: "verifierAddresses", + type: "address[]", + }, + ], + name: "batchUpdateDscCircuitVerifiers", + outputs: [], + stateMutability: "nonpayable", + type: "function", + }, + { + inputs: [ + { + internalType: "uint256[]", + name: "typeIds", + type: "uint256[]", + }, + { + internalType: "address[]", + name: "verifierAddresses", + type: "address[]", + }, + ], + name: "batchUpdateRegisterCircuitVerifiers", + outputs: [], + stateMutability: "nonpayable", + type: "function", + }, + { + inputs: [ + { + internalType: "bytes32[]", + name: "attestationIds", + type: "bytes32[]", + }, + { + internalType: "address[]", + name: "registryAddresses", + type: "address[]", + }, + { + internalType: "address[]", + name: "vcAndDiscloseCircuitVerifierAddresses", + type: "address[]", + }, + { + internalType: "uint256[]", + name: "registerCircuitVerifierIds", + type: "uint256[]", + }, + { + internalType: "address[]", + name: "registerCircuitVerifierAddresses", + type: "address[]", + }, + { + internalType: "uint256[]", + name: "dscCircuitVerifierIds", + type: "uint256[]", + }, + { + internalType: "address[]", + name: "dscCircuitVerifierAddresses", + type: "address[]", + }, + ], + name: "initialize", + outputs: [], + stateMutability: "nonpayable", + type: "function", + }, + { + inputs: [], + name: "owner", + outputs: [ + { + internalType: "address", + name: "", + type: "address", + }, + ], + stateMutability: "view", + type: "function", + }, + { + inputs: [], + name: "pendingOwner", + outputs: [ + { + internalType: "address", + name: "", + type: "address", + }, + ], + stateMutability: "view", + type: "function", + }, + { + inputs: [], + name: "proxiableUUID", + outputs: [ + { + internalType: "bytes32", + name: "", + type: "bytes32", + }, + ], + stateMutability: "view", + type: "function", + }, + { + inputs: [ + { + internalType: "bytes32", + name: "attestationId", + type: "bytes32", + }, + { + internalType: "uint256", + name: "registerCircuitVerifierId", + type: "uint256", + }, + { + components: [ + { + internalType: "uint256[2]", + name: "a", + type: "uint256[2]", + }, + { + internalType: "uint256[2][2]", + name: "b", + type: "uint256[2][2]", + }, + { + internalType: "uint256[2]", + name: "c", + type: "uint256[2]", + }, + { + internalType: "uint256[3]", + name: "pubSignals", + type: "uint256[3]", + }, + ], + internalType: "struct IRegisterCircuitVerifier.RegisterCircuitProof", + name: "registerCircuitProof", + type: "tuple", + }, + ], + name: "registerCommitment", + outputs: [], + stateMutability: "nonpayable", + type: "function", + }, + { + inputs: [ + { + internalType: "bytes32", + name: "attestationId", + type: "bytes32", + }, + { + internalType: "uint256", + name: "dscCircuitVerifierId", + type: "uint256", + }, + { + components: [ + { + internalType: "uint256[2]", + name: "a", + type: "uint256[2]", + }, + { + internalType: "uint256[2][2]", + name: "b", + type: "uint256[2][2]", + }, + { + internalType: "uint256[2]", + name: "c", + type: "uint256[2]", + }, + { + internalType: "uint256[2]", + name: "pubSignals", + type: "uint256[2]", + }, + ], + internalType: "struct IDscCircuitVerifier.DscCircuitProof", + name: "dscCircuitProof", + type: "tuple", + }, + ], + name: "registerDscKeyCommitment", + outputs: [], + stateMutability: "nonpayable", + type: "function", + }, + { + inputs: [ + { + internalType: "bytes32", + name: "attestationId", + type: "bytes32", + }, + ], + name: "registry", + outputs: [ + { + internalType: "address", + name: "", + type: "address", + }, + ], + stateMutability: "view", + type: "function", + }, + { + inputs: [], + name: "renounceOwnership", + outputs: [], + stateMutability: "nonpayable", + type: "function", + }, + { + inputs: [ + { + internalType: "uint256", + name: "typeId", + type: "uint256", + }, + ], + name: "sigTypeToDscCircuitVerifiers", + outputs: [ + { + internalType: "address", + name: "", + type: "address", + }, + ], + stateMutability: "view", + type: "function", + }, + { + inputs: [ + { + internalType: "uint256", + name: "typeId", + type: "uint256", + }, + ], + name: "sigTypeToRegisterCircuitVerifiers", + outputs: [ + { + internalType: "address", + name: "", + type: "address", + }, + ], + stateMutability: "view", + type: "function", + }, + { + inputs: [ + { + internalType: "address", + name: "newOwner", + type: "address", + }, + ], + name: "transferOwnership", + outputs: [], + stateMutability: "nonpayable", + type: "function", + }, + { + inputs: [ + { + internalType: "uint256", + name: "typeId", + type: "uint256", + }, + { + internalType: "address", + name: "verifierAddress", + type: "address", + }, + ], + name: "updateDscVerifier", + outputs: [], + stateMutability: "nonpayable", + type: "function", + }, + { + inputs: [ + { + internalType: "uint256", + name: "typeId", + type: "uint256", + }, + { + internalType: "address", + name: "verifierAddress", + type: "address", + }, + ], + name: "updateRegisterCircuitVerifier", + outputs: [], + stateMutability: "nonpayable", + type: "function", + }, + { + inputs: [ + { + internalType: "bytes32", + name: "attestationId", + type: "bytes32", + }, + { + internalType: "address", + name: "registryAddress", + type: "address", + }, + ], + name: "updateRegistry", + outputs: [], + stateMutability: "nonpayable", + type: "function", + }, + { + inputs: [ + { + internalType: "bytes32", + name: "attestationId", + type: "bytes32", + }, + { + internalType: "address", + name: "vcAndDiscloseCircuitVerifierAddress", + type: "address", + }, + ], + name: "updateVcAndDiscloseCircuit", + outputs: [], + stateMutability: "nonpayable", + type: "function", + }, + { + inputs: [ + { + internalType: "address", + name: "newImplementation", + type: "address", + }, + { + internalType: "bytes", + name: "data", + type: "bytes", + }, + ], + name: "upgradeToAndCall", + outputs: [], + stateMutability: "payable", + type: "function", + }, + { + inputs: [ + { + internalType: "bytes32", + name: "attestationId", + type: "bytes32", + }, + ], + name: "vcAndDiscloseCircuitVerifier", + outputs: [ + { + internalType: "address", + name: "", + type: "address", + }, + ], + stateMutability: "view", + type: "function", + }, + { + inputs: [ + { + internalType: "bytes", + name: "proofData", + type: "bytes", + }, + ], + name: "verifyVcAndDisclose", + outputs: [ + { + internalType: "bytes", + name: "result", + type: "bytes", + }, + ], + stateMutability: "view", + type: "function", + }, +] as const; + +export class IdentityVerificationHubImpl__factory { + static readonly abi = _abi; + static createInterface(): IdentityVerificationHubImplInterface { + return new Interface(_abi) as IdentityVerificationHubImplInterface; + } + static connect( + address: string, + runner?: ContractRunner | null + ): IdentityVerificationHubImpl { + return new Contract( + address, + _abi, + runner + ) as unknown as IdentityVerificationHubImpl; + } +} diff --git a/sdk/core/app/contracts/factories/index.ts b/sdk/core/app/contracts/factories/index.ts new file mode 100644 index 000000000..1a0b7aee7 --- /dev/null +++ b/sdk/core/app/contracts/factories/index.ts @@ -0,0 +1,4 @@ +/* Autogenerated file. Do not edit manually. */ +/* tslint:disable */ +/* eslint-disable */ +export { IdentityVerificationHubImpl__factory } from "./IdentityVerificationHubImpl__factory"; diff --git a/sdk/core/app/contracts/index.ts b/sdk/core/app/contracts/index.ts new file mode 100644 index 000000000..a7318c94b --- /dev/null +++ b/sdk/core/app/contracts/index.ts @@ -0,0 +1,6 @@ +/* Autogenerated file. Do not edit manually. */ +/* tslint:disable */ +/* eslint-disable */ +export type { IdentityVerificationHubImpl } from "./IdentityVerificationHubImpl"; +export * as factories from "./factories"; +export { IdentityVerificationHubImpl__factory } from "./factories/IdentityVerificationHubImpl__factory"; diff --git a/sdk/core/package.json b/sdk/core/package.json index 19b13fa14..0b88d17a6 100644 --- a/sdk/core/package.json +++ b/sdk/core/package.json @@ -49,6 +49,7 @@ "uuid": "^11.1.0" }, "devDependencies": { + "@typechain/ethers-v6": "^0.5.1", "@types/chai": "^4.3.6", "@types/chai-as-promised": "^7.1.8", "@types/circomlibjs": "^0.1.6", @@ -63,6 +64,7 @@ "ts-loader": "^9.5.1", "ts-node": "^10.9.2", "tsup": "^8.5.0", + "typechain": "^8.3.2", "typescript": "^5.4.5" }, "publishConfig": { diff --git a/sdk/core/scripts/copyAbi.sh b/sdk/core/scripts/copyAbi.sh index 8820f135c..f18500c88 100644 --- a/sdk/core/scripts/copyAbi.sh +++ b/sdk/core/scripts/copyAbi.sh @@ -35,4 +35,4 @@ echo "Written ABI for IdentityRegistryImplV1 to: $DEST_REGISTRY_TS" echo "$OUTPUT_VERIFYALL" > "$DEST_VERIFYALL_TS" echo "Written ABI for VerifyAll to: $DEST_VERIFYALL_TS" -echo "ABI files copied and written successfully." \ No newline at end of file +echo "ABI files copied and written successfully." diff --git a/sdk/core/scripts/fix-imports.js b/sdk/core/scripts/fix-imports.js new file mode 100644 index 000000000..32702218b --- /dev/null +++ b/sdk/core/scripts/fix-imports.js @@ -0,0 +1,26 @@ +import { readdir, readFile, writeFile } from 'fs/promises'; +import { join } from 'path'; + +async function fixImports() { + const typechainDir = join(process.cwd(), 'src', 'typechain-types'); + + // Read all files in the typechain-types directory + const files = await readdir(typechainDir); + + for (const file of files) { + if (file.endsWith('.ts')) { + const filePath = join(typechainDir, file); + const content = await readFile(filePath, 'utf-8'); + + // Add .js extension to all relative imports + const modifiedContent = content.replace( + /from ['"](\.\/[^'"]+)['"]/g, + 'from "$1.js"' + ); + + await writeFile(filePath, modifiedContent); + } + } +} + +fixImports().catch(console.error); diff --git a/sdk/core/src/SelfBackendVerifier.ts b/sdk/core/src/SelfBackendVerifier.ts index 6697a932d..6ed1ef556 100644 --- a/sdk/core/src/SelfBackendVerifier.ts +++ b/sdk/core/src/SelfBackendVerifier.ts @@ -1,285 +1,285 @@ -import { registryAbi } from './abi/IdentityRegistryImplV1.js'; -import { verifyAllAbi } from './abi/VerifyAll.js'; -import { - REGISTRY_ADDRESS, - VERIFYALL_ADDRESS, - REGISTRY_ADDRESS_STAGING, - VERIFYALL_ADDRESS_STAGING, -} from './constants/contractAddresses.js'; import { ethers } from 'ethers'; -import { PublicSignals } from 'snarkjs'; -import type { SelfVerificationResult } from '@selfxyz/common/utils/selfAttestation'; -import { castToUserIdentifier, UserIdType } from '@selfxyz/common/utils/circuits/uuid'; -import { - CIRCUIT_CONSTANTS, - revealedDataTypes, - Country3LetterCode, - commonNames, -} from '@selfxyz/common'; -import { packForbiddenCountriesList } from '@selfxyz/common/utils/contracts/formatCallData'; import { hashEndpointWithScope } from '@selfxyz/common/utils/scope'; +import { IdentityVerificationHubImpl, IdentityVerificationHubImpl__factory } from './typechain-types/index.js'; const CELO_MAINNET_RPC_URL = 'https://forno.celo.org'; const CELO_TESTNET_RPC_URL = 'https://alfajores-forno.celo-testnet.org'; +const IDENTITY_VERIFICATION_HUB_ADDRESS = '0x0000000000000000000000000000000000000000'; +const IDENTITY_VERIFICATION_HUB_ADDRESS_STAGING = '0x0000000000000000000000000000000000000000'; + export class SelfBackendVerifier { protected scope: string; - protected attestationId: number = 1; - protected user_identifier_type: UserIdType = 'uuid'; - protected targetRootTimestamp: { enabled: boolean; value: number } = { - enabled: false, - value: 0, - }; - - protected nationality: { - enabled: boolean; - value: Country3LetterCode; - } = { - enabled: false, - value: '' as Country3LetterCode, - }; - protected minimumAge: { enabled: boolean; value: string } = { - enabled: false, - value: '18', - }; - protected excludedCountries: { - enabled: boolean; - value: Country3LetterCode[]; - } = { - enabled: false, - value: [], - }; - protected passportNoOfac: boolean = false; - protected nameAndDobOfac: boolean = false; - protected nameAndYobOfac: boolean = false; + protected identityVerificationHubContract: IdentityVerificationHubImpl; + protected configStorage; - protected registryContract: ethers.Contract; - protected verifyAllContract: ethers.Contract; - protected mockPassport: boolean; - - constructor( - scope: string, - endpoint: string, - user_identifier_type: UserIdType = 'uuid', - mockPassport: boolean = false - ) { + constructor(scope: string, endpoint: string, mockPassport: boolean = false) { const rpcUrl = mockPassport ? CELO_TESTNET_RPC_URL : CELO_MAINNET_RPC_URL; const provider = new ethers.JsonRpcProvider(rpcUrl); - const registryAddress = mockPassport ? REGISTRY_ADDRESS_STAGING : REGISTRY_ADDRESS; - const verifyAllAddress = mockPassport ? VERIFYALL_ADDRESS_STAGING : VERIFYALL_ADDRESS; - this.registryContract = new ethers.Contract(registryAddress, registryAbi, provider); - this.verifyAllContract = new ethers.Contract(verifyAllAddress, verifyAllAbi, provider); + const identityVerificationHubAddress = mockPassport ? IDENTITY_VERIFICATION_HUB_ADDRESS_STAGING : IDENTITY_VERIFICATION_HUB_ADDRESS; + this.identityVerificationHubContract = IdentityVerificationHubImpl__factory.connect(identityVerificationHubAddress, provider); this.scope = hashEndpointWithScope(endpoint, scope); - this.user_identifier_type = user_identifier_type; - this.mockPassport = mockPassport; } +} - public async verify(proof: any, publicSignals: PublicSignals): Promise { - const forbiddenCountriesListPacked = packForbiddenCountriesList(this.excludedCountries.value); +// export class SelfBackendVerifier { +// protected scope: string; +// protected attestationId: number = 1; +// protected user_identifier_type: UserIdType = 'uuid'; +// protected targetRootTimestamp: { enabled: boolean; value: number } = { +// enabled: false, +// value: 0, +// }; - const isValidScope = - this.scope === publicSignals[CIRCUIT_CONSTANTS.VC_AND_DISCLOSE_SCOPE_INDEX]; +// protected nationality: { +// enabled: boolean; +// value: Country3LetterCode; +// } = { +// enabled: false, +// value: '' as Country3LetterCode, +// }; +// protected minimumAge: { enabled: boolean; value: string } = { +// enabled: false, +// value: '18', +// }; +// protected excludedCountries: { +// enabled: boolean; +// value: Country3LetterCode[]; +// } = { +// enabled: false, +// value: [], +// }; +// protected passportNoOfac: boolean = false; +// protected nameAndDobOfac: boolean = false; +// protected nameAndYobOfac: boolean = false; - const isValidAttestationId = - this.attestationId.toString() === - publicSignals[CIRCUIT_CONSTANTS.VC_AND_DISCLOSE_ATTESTATION_ID_INDEX]; +// protected registryContract: ethers.Contract; +// protected verifyAllContract: ethers.Contract; +// protected mockPassport: boolean; - const vcAndDiscloseHubProof = { - olderThanEnabled: this.minimumAge.enabled, - olderThan: this.minimumAge.value, - forbiddenCountriesEnabled: this.excludedCountries.enabled, - forbiddenCountriesListPacked: forbiddenCountriesListPacked, - ofacEnabled: [this.passportNoOfac, this.nameAndDobOfac, this.nameAndYobOfac], - vcAndDiscloseProof: { - a: proof.a, - b: [ - [proof.b[0][1], proof.b[0][0]], - [proof.b[1][1], proof.b[1][0]], - ], - c: proof.c, - pubSignals: publicSignals, - }, - }; +// constructor( +// scope: string, +// endpoint: string, +// user_identifier_type: UserIdType = 'uuid', +// mockPassport: boolean = false +// ) { +// const rpcUrl = mockPassport ? CELO_TESTNET_RPC_URL : CELO_MAINNET_RPC_URL; +// const provider = new ethers.JsonRpcProvider(rpcUrl); +// const registryAddress = mockPassport ? REGISTRY_ADDRESS_STAGING : REGISTRY_ADDRESS; +// const verifyAllAddress = mockPassport ? VERIFYALL_ADDRESS_STAGING : VERIFYALL_ADDRESS; +// this.registryContract = new ethers.Contract(registryAddress, registryAbi, provider); +// this.verifyAllContract = new ethers.Contract(verifyAllAddress, verifyAllAbi, provider); +// this.scope = hashEndpointWithScope(endpoint, scope); +// this.user_identifier_type = user_identifier_type; +// this.mockPassport = mockPassport; +// } - const types = [ - revealedDataTypes.issuing_state, - revealedDataTypes.name, - revealedDataTypes.passport_number, - revealedDataTypes.nationality, - revealedDataTypes.date_of_birth, - revealedDataTypes.gender, - revealedDataTypes.expiry_date, - ]; +// public async verify(proof: any, publicSignals: PublicSignals): Promise { +// const forbiddenCountriesListPacked = packForbiddenCountriesList(this.excludedCountries.value); - if (this.minimumAge.enabled) { - types.push(revealedDataTypes.older_than); - } +// const isValidScope = +// this.scope === publicSignals[CIRCUIT_CONSTANTS.VC_AND_DISCLOSE_SCOPE_INDEX]; - if (this.passportNoOfac) { - types.push(revealedDataTypes.passport_no_ofac); - } +// const isValidAttestationId = +// this.attestationId.toString() === +// publicSignals[CIRCUIT_CONSTANTS.VC_AND_DISCLOSE_ATTESTATION_ID_INDEX]; - if (this.nameAndDobOfac) { - types.push(revealedDataTypes.name_and_dob_ofac); - } +// const vcAndDiscloseHubProof = { +// olderThanEnabled: this.minimumAge.enabled, +// olderThan: this.minimumAge.value, +// forbiddenCountriesEnabled: this.excludedCountries.enabled, +// forbiddenCountriesListPacked: forbiddenCountriesListPacked, +// ofacEnabled: [this.passportNoOfac, this.nameAndDobOfac, this.nameAndYobOfac], +// vcAndDiscloseProof: { +// a: proof.a, +// b: [ +// [proof.b[0][1], proof.b[0][0]], +// [proof.b[1][1], proof.b[1][0]], +// ], +// c: proof.c, +// pubSignals: publicSignals, +// }, +// }; - if (this.nameAndYobOfac) { - types.push(revealedDataTypes.name_and_yob_ofac); - } +// const types = [ +// revealedDataTypes.issuing_state, +// revealedDataTypes.name, +// revealedDataTypes.passport_number, +// revealedDataTypes.nationality, +// revealedDataTypes.date_of_birth, +// revealedDataTypes.gender, +// revealedDataTypes.expiry_date, +// ]; - const currentRoot = await this.registryContract.getIdentityCommitmentMerkleRoot(); - const timestamp = await this.registryContract.rootTimestamps(currentRoot); +// if (this.minimumAge.enabled) { +// types.push(revealedDataTypes.older_than); +// } - const user_identifier = castToUserIdentifier( - BigInt(publicSignals[CIRCUIT_CONSTANTS.VC_AND_DISCLOSE_USER_IDENTIFIER_INDEX]), - this.user_identifier_type - ); +// if (this.passportNoOfac) { +// types.push(revealedDataTypes.passport_no_ofac); +// } - let result: any; - try { - result = await this.verifyAllContract.verifyAll(timestamp, vcAndDiscloseHubProof, types); - } catch (error: any) { - let errorMessage = error instanceof Error ? error.message : 'Unknown error'; - if ( - error && - typeof error === 'object' && - error.message && - error.message.includes('INVALID_FORBIDDEN_COUNTRIES') - ) { - errorMessage = - 'The forbidden countries list in the backend does not match the list provided in the frontend SDK. Please ensure both lists are identical.'; - } +// if (this.nameAndDobOfac) { +// types.push(revealedDataTypes.name_and_dob_ofac); +// } - return { - isValid: false, - isValidDetails: { - isValidScope: false, - isValidAttestationId: false, - isValidProof: false, - isValidNationality: false, - }, - userId: user_identifier, - application: this.scope, - nullifier: publicSignals[CIRCUIT_CONSTANTS.VC_AND_DISCLOSE_NULLIFIER_INDEX], - credentialSubject: {}, - proof: { - value: { - proof: proof, - publicSignals: publicSignals, - }, - }, - error: errorMessage, - }; - } +// if (this.nameAndYobOfac) { +// types.push(revealedDataTypes.name_and_yob_ofac); +// } - let isValidNationality = true; - if (this.nationality.enabled) { - const nationality = result[0][revealedDataTypes.nationality]; - isValidNationality = nationality === this.nationality.value; - } +// const currentRoot = await this.registryContract.getIdentityCommitmentMerkleRoot(); +// const timestamp = await this.registryContract.rootTimestamps(currentRoot); - const credentialSubject = { - merkle_root: publicSignals[CIRCUIT_CONSTANTS.VC_AND_DISCLOSE_MERKLE_ROOT_INDEX], - attestation_id: this.attestationId.toString(), - current_date: new Date().toISOString(), - issuing_state: result[0][revealedDataTypes.issuing_state], - name: result[0][revealedDataTypes.name], - passport_number: result[0][revealedDataTypes.passport_number], - nationality: result[0][revealedDataTypes.nationality], - date_of_birth: result[0][revealedDataTypes.date_of_birth], - gender: result[0][revealedDataTypes.gender], - expiry_date: result[0][revealedDataTypes.expiry_date], - older_than: result[0][revealedDataTypes.older_than].toString(), - passport_no_ofac: result[0][revealedDataTypes.passport_no_ofac].toString() === '1', - name_and_dob_ofac: result[0][revealedDataTypes.name_and_dob_ofac].toString() === '1', - name_and_yob_ofac: result[0][revealedDataTypes.name_and_yob_ofac].toString() === '1', - }; +// const user_identifier = castToUserIdentifier( +// BigInt(publicSignals[CIRCUIT_CONSTANTS.VC_AND_DISCLOSE_USER_IDENTIFIER_INDEX]), +// this.user_identifier_type +// ); - const attestation: SelfVerificationResult = { - isValid: result[1] && isValidScope && isValidAttestationId && isValidNationality, - isValidDetails: { - isValidScope: isValidScope, - isValidAttestationId: isValidAttestationId, - isValidProof: result[1], - isValidNationality: isValidNationality, - }, - userId: user_identifier, - application: this.scope, - nullifier: publicSignals[CIRCUIT_CONSTANTS.VC_AND_DISCLOSE_NULLIFIER_INDEX], - credentialSubject: credentialSubject, - proof: { - value: { - proof: proof, - publicSignals: publicSignals, - }, - }, - error: result[2], - }; +// let result: any; +// try { +// result = await this.verifyAllContract.verifyAll(timestamp, vcAndDiscloseHubProof, types); +// } catch (error: any) { +// let errorMessage = error instanceof Error ? error.message : 'Unknown error'; +// if ( +// error && +// typeof error === 'object' && +// error.message && +// error.message.includes('INVALID_FORBIDDEN_COUNTRIES') +// ) { +// errorMessage = +// 'The forbidden countries list in the backend does not match the list provided in the frontend SDK. Please ensure both lists are identical.'; +// } - return attestation; - } +// return { +// isValid: false, +// isValidDetails: { +// isValidScope: false, +// isValidAttestationId: false, +// isValidProof: false, +// isValidNationality: false, +// }, +// userId: user_identifier, +// application: this.scope, +// nullifier: publicSignals[CIRCUIT_CONSTANTS.VC_AND_DISCLOSE_NULLIFIER_INDEX], +// credentialSubject: {}, +// proof: { +// value: { +// proof: proof, +// publicSignals: publicSignals, +// }, +// }, +// error: errorMessage, +// }; +// } - setMinimumAge(age: number): this { - if (age <= 0) { - throw new Error('Minimum age must be positive'); - } - if (age > 100) { - throw new Error('Minimum age must be at most 100 years old'); - } - this.minimumAge = { enabled: true, value: age.toString() }; - return this; - } +// let isValidNationality = true; +// if (this.nationality.enabled) { +// const nationality = result[0][revealedDataTypes.nationality]; +// isValidNationality = nationality === this.nationality.value; +// } - setNationality(country: Country3LetterCode): this { - this.nationality = { enabled: true, value: country }; - return this; - } +// const credentialSubject = { +// merkle_root: publicSignals[CIRCUIT_CONSTANTS.VC_AND_DISCLOSE_MERKLE_ROOT_INDEX], +// attestation_id: this.attestationId.toString(), +// current_date: new Date().toISOString(), +// issuing_state: result[0][revealedDataTypes.issuing_state], +// name: result[0][revealedDataTypes.name], +// passport_number: result[0][revealedDataTypes.passport_number], +// nationality: result[0][revealedDataTypes.nationality], +// date_of_birth: result[0][revealedDataTypes.date_of_birth], +// gender: result[0][revealedDataTypes.gender], +// expiry_date: result[0][revealedDataTypes.expiry_date], +// older_than: result[0][revealedDataTypes.older_than].toString(), +// passport_no_ofac: result[0][revealedDataTypes.passport_no_ofac].toString() === '1', +// name_and_dob_ofac: result[0][revealedDataTypes.name_and_dob_ofac].toString() === '1', +// name_and_yob_ofac: result[0][revealedDataTypes.name_and_yob_ofac].toString() === '1', +// }; - /** - * Sets the list of countries to be excluded in the verification. - * This list must exactly match the list configured in the backend. - * - * @param countries Array of 3-letter country codes to exclude - * @returns This instance for method chaining - * @throws Error if more than 40 countries are provided or if any country code is invalid - */ - excludeCountries(...countries: Country3LetterCode[]): this { - if (countries.length > 40) { - throw new Error('Number of excluded countries cannot exceed 40'); - } - // Validate country codes - for (const country of countries) { - if (!country || country.length !== 3) { - throw new Error( - `Invalid country code: "${country}". Country codes must be exactly 3 characters long.` - ); - } - // Check if the country code exists in the list of valid codes (additional check) - const isValidCountry = Object.values(commonNames).some( - (name) => name === country || country in commonNames - ); - if (!isValidCountry) { - throw new Error( - `Unknown country code: "${country}". Please use valid 3-letter ISO country codes.` - ); - } - } - this.excludedCountries = { enabled: true, value: countries }; - return this; - } +// const attestation: SelfVerificationResult = { +// isValid: result[1] && isValidScope && isValidAttestationId && isValidNationality, +// isValidDetails: { +// isValidScope: isValidScope, +// isValidAttestationId: isValidAttestationId, +// isValidProof: result[1], +// isValidNationality: isValidNationality, +// }, +// userId: user_identifier, +// application: this.scope, +// nullifier: publicSignals[CIRCUIT_CONSTANTS.VC_AND_DISCLOSE_NULLIFIER_INDEX], +// credentialSubject: credentialSubject, +// proof: { +// value: { +// proof: proof, +// publicSignals: publicSignals, +// }, +// }, +// error: result[2], +// }; - enablePassportNoOfacCheck(): this { - this.passportNoOfac = true; - return this; - } +// return attestation; +// } - enableNameAndDobOfacCheck(): this { - this.nameAndDobOfac = true; - return this; - } +// setMinimumAge(age: number): this { +// if (age <= 0) { +// throw new Error('Minimum age must be positive'); +// } +// if (age > 100) { +// throw new Error('Minimum age must be at most 100 years old'); +// } +// this.minimumAge = { enabled: true, value: age.toString() }; +// return this; +// } - enableNameAndYobOfacCheck(): this { - this.nameAndYobOfac = true; - return this; - } -} +// setNationality(country: Country3LetterCode): this { +// this.nationality = { enabled: true, value: country }; +// return this; +// } + +// /** +// * Sets the list of countries to be excluded in the verification. +// * This list must exactly match the list configured in the backend. +// * +// * @param countries Array of 3-letter country codes to exclude +// * @returns This instance for method chaining +// * @throws Error if more than 40 countries are provided or if any country code is invalid +// */ +// excludeCountries(...countries: Country3LetterCode[]): this { +// if (countries.length > 40) { +// throw new Error('Number of excluded countries cannot exceed 40'); +// } +// // Validate country codes +// for (const country of countries) { +// if (!country || country.length !== 3) { +// throw new Error( +// `Invalid country code: "${country}". Country codes must be exactly 3 characters long.` +// ); +// } +// // Check if the country code exists in the list of valid codes (additional check) +// const isValidCountry = Object.values(commonNames).some( +// (name) => name === country || country in commonNames +// ); +// if (!isValidCountry) { +// throw new Error( +// `Unknown country code: "${country}". Please use valid 3-letter ISO country codes.` +// ); +// } +// } +// this.excludedCountries = { enabled: true, value: countries }; +// return this; +// } + +// enablePassportNoOfacCheck(): this { +// this.passportNoOfac = true; +// return this; +// } + +// enableNameAndDobOfacCheck(): this { +// this.nameAndDobOfac = true; +// return this; +// } + +// enableNameAndYobOfacCheck(): this { +// this.nameAndYobOfac = true; +// return this; +// } +// } diff --git a/sdk/core/src/abi/IdentityVerificationHubImpl.json b/sdk/core/src/abi/IdentityVerificationHubImpl.json new file mode 100644 index 000000000..824389468 --- /dev/null +++ b/sdk/core/src/abi/IdentityVerificationHubImpl.json @@ -0,0 +1,809 @@ +[ + { + "inputs": [], + "stateMutability": "nonpayable", + "type": "constructor" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "target", + "type": "address" + } + ], + "name": "AddressEmptyCode", + "type": "error" + }, + { + "inputs": [], + "name": "CURRENT_DATE_NOT_IN_VALID_RANGE", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "implementation", + "type": "address" + } + ], + "name": "ERC1967InvalidImplementation", + "type": "error" + }, + { + "inputs": [], + "name": "ERC1967NonPayable", + "type": "error" + }, + { + "inputs": [], + "name": "FailedCall", + "type": "error" + }, + { + "inputs": [], + "name": "INVALID_ATTESTATION_ID", + "type": "error" + }, + { + "inputs": [], + "name": "INVALID_COMMITMENT_ROOT", + "type": "error" + }, + { + "inputs": [], + "name": "INVALID_CSCA_ROOT", + "type": "error" + }, + { + "inputs": [], + "name": "INVALID_DSC_PROOF", + "type": "error" + }, + { + "inputs": [], + "name": "INVALID_FORBIDDEN_COUNTRIES", + "type": "error" + }, + { + "inputs": [], + "name": "INVALID_OFAC", + "type": "error" + }, + { + "inputs": [], + "name": "INVALID_OFAC_ROOT", + "type": "error" + }, + { + "inputs": [], + "name": "INVALID_OLDER_THAN", + "type": "error" + }, + { + "inputs": [], + "name": "INVALID_REGISTER_PROOF", + "type": "error" + }, + { + "inputs": [], + "name": "INVALID_REVEALED_DATA_TYPE", + "type": "error" + }, + { + "inputs": [], + "name": "INVALID_VC_AND_DISCLOSE_PROOF", + "type": "error" + }, + { + "inputs": [], + "name": "InvalidDateDigit", + "type": "error" + }, + { + "inputs": [], + "name": "InvalidDateLength", + "type": "error" + }, + { + "inputs": [], + "name": "InvalidDayRange", + "type": "error" + }, + { + "inputs": [], + "name": "InvalidFieldElement", + "type": "error" + }, + { + "inputs": [], + "name": "InvalidInitialization", + "type": "error" + }, + { + "inputs": [], + "name": "InvalidMonthRange", + "type": "error" + }, + { + "inputs": [], + "name": "InvalidYearRange", + "type": "error" + }, + { + "inputs": [], + "name": "LENGTH_MISMATCH", + "type": "error" + }, + { + "inputs": [], + "name": "NO_VERIFIER_SET", + "type": "error" + }, + { + "inputs": [], + "name": "NotInitializing", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "owner", + "type": "address" + } + ], + "name": "OwnableInvalidOwner", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "account", + "type": "address" + } + ], + "name": "OwnableUnauthorizedAccount", + "type": "error" + }, + { + "inputs": [], + "name": "UUPSUnauthorizedCallContext", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "bytes32", + "name": "slot", + "type": "bytes32" + } + ], + "name": "UUPSUnsupportedProxiableUUID", + "type": "error" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint256", + "name": "typeId", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "address", + "name": "verifier", + "type": "address" + } + ], + "name": "DscCircuitVerifierUpdated", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "bytes32[]", + "name": "attestationIds", + "type": "bytes32[]" + }, + { + "indexed": false, + "internalType": "address[]", + "name": "registryAddresses", + "type": "address[]" + }, + { + "indexed": false, + "internalType": "address[]", + "name": "vcAndDiscloseCircuitVerifiers", + "type": "address[]" + }, + { + "indexed": false, + "internalType": "uint256[]", + "name": "registerCircuitVerifierIds", + "type": "uint256[]" + }, + { + "indexed": false, + "internalType": "address[]", + "name": "registerCircuitVerifiers", + "type": "address[]" + }, + { + "indexed": false, + "internalType": "uint256[]", + "name": "dscCircuitVerifierIds", + "type": "uint256[]" + }, + { + "indexed": false, + "internalType": "address[]", + "name": "dscCircuitVerifiers", + "type": "address[]" + } + ], + "name": "HubInitialized", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint64", + "name": "version", + "type": "uint64" + } + ], + "name": "Initialized", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "previousOwner", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "newOwner", + "type": "address" + } + ], + "name": "OwnershipTransferStarted", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "previousOwner", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "newOwner", + "type": "address" + } + ], + "name": "OwnershipTransferred", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint256", + "name": "typeId", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "address", + "name": "verifier", + "type": "address" + } + ], + "name": "RegisterCircuitVerifierUpdated", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "bytes32", + "name": "attestationId", + "type": "bytes32" + }, + { + "indexed": false, + "internalType": "address", + "name": "registry", + "type": "address" + } + ], + "name": "RegistryUpdated", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "implementation", + "type": "address" + } + ], + "name": "Upgraded", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "bytes32", + "name": "attestationId", + "type": "bytes32" + }, + { + "indexed": false, + "internalType": "address", + "name": "vcAndDiscloseCircuitVerifier", + "type": "address" + } + ], + "name": "VcAndDiscloseCircuitUpdated", + "type": "event" + }, + { + "inputs": [], + "name": "UPGRADE_INTERFACE_VERSION", + "outputs": [ + { + "internalType": "string", + "name": "", + "type": "string" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "acceptOwnership", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256[]", + "name": "typeIds", + "type": "uint256[]" + }, + { + "internalType": "address[]", + "name": "verifierAddresses", + "type": "address[]" + } + ], + "name": "batchUpdateDscCircuitVerifiers", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256[]", + "name": "typeIds", + "type": "uint256[]" + }, + { + "internalType": "address[]", + "name": "verifierAddresses", + "type": "address[]" + } + ], + "name": "batchUpdateRegisterCircuitVerifiers", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes32[]", + "name": "attestationIds", + "type": "bytes32[]" + }, + { + "internalType": "address[]", + "name": "registryAddresses", + "type": "address[]" + }, + { + "internalType": "address[]", + "name": "vcAndDiscloseCircuitVerifierAddresses", + "type": "address[]" + }, + { + "internalType": "uint256[]", + "name": "registerCircuitVerifierIds", + "type": "uint256[]" + }, + { + "internalType": "address[]", + "name": "registerCircuitVerifierAddresses", + "type": "address[]" + }, + { + "internalType": "uint256[]", + "name": "dscCircuitVerifierIds", + "type": "uint256[]" + }, + { + "internalType": "address[]", + "name": "dscCircuitVerifierAddresses", + "type": "address[]" + } + ], + "name": "initialize", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "owner", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "pendingOwner", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "proxiableUUID", + "outputs": [ + { + "internalType": "bytes32", + "name": "", + "type": "bytes32" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes32", + "name": "attestationId", + "type": "bytes32" + }, + { + "internalType": "uint256", + "name": "registerCircuitVerifierId", + "type": "uint256" + }, + { + "components": [ + { + "internalType": "uint256[2]", + "name": "a", + "type": "uint256[2]" + }, + { + "internalType": "uint256[2][2]", + "name": "b", + "type": "uint256[2][2]" + }, + { + "internalType": "uint256[2]", + "name": "c", + "type": "uint256[2]" + }, + { + "internalType": "uint256[3]", + "name": "pubSignals", + "type": "uint256[3]" + } + ], + "internalType": "struct IRegisterCircuitVerifier.RegisterCircuitProof", + "name": "registerCircuitProof", + "type": "tuple" + } + ], + "name": "registerCommitment", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes32", + "name": "attestationId", + "type": "bytes32" + }, + { + "internalType": "uint256", + "name": "dscCircuitVerifierId", + "type": "uint256" + }, + { + "components": [ + { + "internalType": "uint256[2]", + "name": "a", + "type": "uint256[2]" + }, + { + "internalType": "uint256[2][2]", + "name": "b", + "type": "uint256[2][2]" + }, + { + "internalType": "uint256[2]", + "name": "c", + "type": "uint256[2]" + }, + { + "internalType": "uint256[2]", + "name": "pubSignals", + "type": "uint256[2]" + } + ], + "internalType": "struct IDscCircuitVerifier.DscCircuitProof", + "name": "dscCircuitProof", + "type": "tuple" + } + ], + "name": "registerDscKeyCommitment", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes32", + "name": "attestationId", + "type": "bytes32" + } + ], + "name": "registry", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "renounceOwnership", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "typeId", + "type": "uint256" + } + ], + "name": "sigTypeToDscCircuitVerifiers", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "typeId", + "type": "uint256" + } + ], + "name": "sigTypeToRegisterCircuitVerifiers", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "newOwner", + "type": "address" + } + ], + "name": "transferOwnership", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "typeId", + "type": "uint256" + }, + { + "internalType": "address", + "name": "verifierAddress", + "type": "address" + } + ], + "name": "updateDscVerifier", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "typeId", + "type": "uint256" + }, + { + "internalType": "address", + "name": "verifierAddress", + "type": "address" + } + ], + "name": "updateRegisterCircuitVerifier", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes32", + "name": "attestationId", + "type": "bytes32" + }, + { + "internalType": "address", + "name": "registryAddress", + "type": "address" + } + ], + "name": "updateRegistry", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes32", + "name": "attestationId", + "type": "bytes32" + }, + { + "internalType": "address", + "name": "vcAndDiscloseCircuitVerifierAddress", + "type": "address" + } + ], + "name": "updateVcAndDiscloseCircuit", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "newImplementation", + "type": "address" + }, + { + "internalType": "bytes", + "name": "data", + "type": "bytes" + } + ], + "name": "upgradeToAndCall", + "outputs": [], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes32", + "name": "attestationId", + "type": "bytes32" + } + ], + "name": "vcAndDiscloseCircuitVerifier", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes", + "name": "proofData", + "type": "bytes" + } + ], + "name": "verifyVcAndDisclose", + "outputs": [ + { + "internalType": "bytes", + "name": "result", + "type": "bytes" + } + ], + "stateMutability": "view", + "type": "function" + } +] diff --git a/sdk/core/src/typechain-types/IdentityVerificationHubImpl.ts b/sdk/core/src/typechain-types/IdentityVerificationHubImpl.ts new file mode 100644 index 000000000..ddedddc7a --- /dev/null +++ b/sdk/core/src/typechain-types/IdentityVerificationHubImpl.ts @@ -0,0 +1,886 @@ +/* Autogenerated file. Do not edit manually. */ +/* tslint:disable */ +/* eslint-disable */ +import type { + BaseContract, + BigNumberish, + BytesLike, + FunctionFragment, + Result, + Interface, + EventFragment, + AddressLike, + ContractRunner, + ContractMethod, + Listener, +} from "ethers"; +import type { + TypedContractEvent, + TypedDeferredTopicFilter, + TypedEventLog, + TypedLogDescription, + TypedListener, + TypedContractMethod, +} from "./common.js"; + +export declare namespace IRegisterCircuitVerifier { + export type RegisterCircuitProofStruct = { + a: [BigNumberish, BigNumberish]; + b: [[BigNumberish, BigNumberish], [BigNumberish, BigNumberish]]; + c: [BigNumberish, BigNumberish]; + pubSignals: [BigNumberish, BigNumberish, BigNumberish]; + }; + + export type RegisterCircuitProofStructOutput = [ + a: [bigint, bigint], + b: [[bigint, bigint], [bigint, bigint]], + c: [bigint, bigint], + pubSignals: [bigint, bigint, bigint] + ] & { + a: [bigint, bigint]; + b: [[bigint, bigint], [bigint, bigint]]; + c: [bigint, bigint]; + pubSignals: [bigint, bigint, bigint]; + }; +} + +export declare namespace IDscCircuitVerifier { + export type DscCircuitProofStruct = { + a: [BigNumberish, BigNumberish]; + b: [[BigNumberish, BigNumberish], [BigNumberish, BigNumberish]]; + c: [BigNumberish, BigNumberish]; + pubSignals: [BigNumberish, BigNumberish]; + }; + + export type DscCircuitProofStructOutput = [ + a: [bigint, bigint], + b: [[bigint, bigint], [bigint, bigint]], + c: [bigint, bigint], + pubSignals: [bigint, bigint] + ] & { + a: [bigint, bigint]; + b: [[bigint, bigint], [bigint, bigint]]; + c: [bigint, bigint]; + pubSignals: [bigint, bigint]; + }; +} + +export interface IdentityVerificationHubImplInterface extends Interface { + getFunction( + nameOrSignature: + | "UPGRADE_INTERFACE_VERSION" + | "acceptOwnership" + | "batchUpdateDscCircuitVerifiers" + | "batchUpdateRegisterCircuitVerifiers" + | "initialize" + | "owner" + | "pendingOwner" + | "proxiableUUID" + | "registerCommitment" + | "registerDscKeyCommitment" + | "registry" + | "renounceOwnership" + | "sigTypeToDscCircuitVerifiers" + | "sigTypeToRegisterCircuitVerifiers" + | "transferOwnership" + | "updateDscVerifier" + | "updateRegisterCircuitVerifier" + | "updateRegistry" + | "updateVcAndDiscloseCircuit" + | "upgradeToAndCall" + | "vcAndDiscloseCircuitVerifier" + | "verifyVcAndDisclose" + ): FunctionFragment; + + getEvent( + nameOrSignatureOrTopic: + | "DscCircuitVerifierUpdated" + | "HubInitialized" + | "Initialized" + | "OwnershipTransferStarted" + | "OwnershipTransferred" + | "RegisterCircuitVerifierUpdated" + | "RegistryUpdated" + | "Upgraded" + | "VcAndDiscloseCircuitUpdated" + ): EventFragment; + + encodeFunctionData( + functionFragment: "UPGRADE_INTERFACE_VERSION", + values?: undefined + ): string; + encodeFunctionData( + functionFragment: "acceptOwnership", + values?: undefined + ): string; + encodeFunctionData( + functionFragment: "batchUpdateDscCircuitVerifiers", + values: [BigNumberish[], AddressLike[]] + ): string; + encodeFunctionData( + functionFragment: "batchUpdateRegisterCircuitVerifiers", + values: [BigNumberish[], AddressLike[]] + ): string; + encodeFunctionData( + functionFragment: "initialize", + values: [ + BytesLike[], + AddressLike[], + AddressLike[], + BigNumberish[], + AddressLike[], + BigNumberish[], + AddressLike[] + ] + ): string; + encodeFunctionData(functionFragment: "owner", values?: undefined): string; + encodeFunctionData( + functionFragment: "pendingOwner", + values?: undefined + ): string; + encodeFunctionData( + functionFragment: "proxiableUUID", + values?: undefined + ): string; + encodeFunctionData( + functionFragment: "registerCommitment", + values: [ + BytesLike, + BigNumberish, + IRegisterCircuitVerifier.RegisterCircuitProofStruct + ] + ): string; + encodeFunctionData( + functionFragment: "registerDscKeyCommitment", + values: [BytesLike, BigNumberish, IDscCircuitVerifier.DscCircuitProofStruct] + ): string; + encodeFunctionData(functionFragment: "registry", values: [BytesLike]): string; + encodeFunctionData( + functionFragment: "renounceOwnership", + values?: undefined + ): string; + encodeFunctionData( + functionFragment: "sigTypeToDscCircuitVerifiers", + values: [BigNumberish] + ): string; + encodeFunctionData( + functionFragment: "sigTypeToRegisterCircuitVerifiers", + values: [BigNumberish] + ): string; + encodeFunctionData( + functionFragment: "transferOwnership", + values: [AddressLike] + ): string; + encodeFunctionData( + functionFragment: "updateDscVerifier", + values: [BigNumberish, AddressLike] + ): string; + encodeFunctionData( + functionFragment: "updateRegisterCircuitVerifier", + values: [BigNumberish, AddressLike] + ): string; + encodeFunctionData( + functionFragment: "updateRegistry", + values: [BytesLike, AddressLike] + ): string; + encodeFunctionData( + functionFragment: "updateVcAndDiscloseCircuit", + values: [BytesLike, AddressLike] + ): string; + encodeFunctionData( + functionFragment: "upgradeToAndCall", + values: [AddressLike, BytesLike] + ): string; + encodeFunctionData( + functionFragment: "vcAndDiscloseCircuitVerifier", + values: [BytesLike] + ): string; + encodeFunctionData( + functionFragment: "verifyVcAndDisclose", + values: [BytesLike] + ): string; + + decodeFunctionResult( + functionFragment: "UPGRADE_INTERFACE_VERSION", + data: BytesLike + ): Result; + decodeFunctionResult( + functionFragment: "acceptOwnership", + data: BytesLike + ): Result; + decodeFunctionResult( + functionFragment: "batchUpdateDscCircuitVerifiers", + data: BytesLike + ): Result; + decodeFunctionResult( + functionFragment: "batchUpdateRegisterCircuitVerifiers", + data: BytesLike + ): Result; + decodeFunctionResult(functionFragment: "initialize", data: BytesLike): Result; + decodeFunctionResult(functionFragment: "owner", data: BytesLike): Result; + decodeFunctionResult( + functionFragment: "pendingOwner", + data: BytesLike + ): Result; + decodeFunctionResult( + functionFragment: "proxiableUUID", + data: BytesLike + ): Result; + decodeFunctionResult( + functionFragment: "registerCommitment", + data: BytesLike + ): Result; + decodeFunctionResult( + functionFragment: "registerDscKeyCommitment", + data: BytesLike + ): Result; + decodeFunctionResult(functionFragment: "registry", data: BytesLike): Result; + decodeFunctionResult( + functionFragment: "renounceOwnership", + data: BytesLike + ): Result; + decodeFunctionResult( + functionFragment: "sigTypeToDscCircuitVerifiers", + data: BytesLike + ): Result; + decodeFunctionResult( + functionFragment: "sigTypeToRegisterCircuitVerifiers", + data: BytesLike + ): Result; + decodeFunctionResult( + functionFragment: "transferOwnership", + data: BytesLike + ): Result; + decodeFunctionResult( + functionFragment: "updateDscVerifier", + data: BytesLike + ): Result; + decodeFunctionResult( + functionFragment: "updateRegisterCircuitVerifier", + data: BytesLike + ): Result; + decodeFunctionResult( + functionFragment: "updateRegistry", + data: BytesLike + ): Result; + decodeFunctionResult( + functionFragment: "updateVcAndDiscloseCircuit", + data: BytesLike + ): Result; + decodeFunctionResult( + functionFragment: "upgradeToAndCall", + data: BytesLike + ): Result; + decodeFunctionResult( + functionFragment: "vcAndDiscloseCircuitVerifier", + data: BytesLike + ): Result; + decodeFunctionResult( + functionFragment: "verifyVcAndDisclose", + data: BytesLike + ): Result; +} + +export namespace DscCircuitVerifierUpdatedEvent { + export type InputTuple = [typeId: BigNumberish, verifier: AddressLike]; + export type OutputTuple = [typeId: bigint, verifier: string]; + export interface OutputObject { + typeId: bigint; + verifier: string; + } + export type Event = TypedContractEvent; + export type Filter = TypedDeferredTopicFilter; + export type Log = TypedEventLog; + export type LogDescription = TypedLogDescription; +} + +export namespace HubInitializedEvent { + export type InputTuple = [ + attestationIds: BytesLike[], + registryAddresses: AddressLike[], + vcAndDiscloseCircuitVerifiers: AddressLike[], + registerCircuitVerifierIds: BigNumberish[], + registerCircuitVerifiers: AddressLike[], + dscCircuitVerifierIds: BigNumberish[], + dscCircuitVerifiers: AddressLike[] + ]; + export type OutputTuple = [ + attestationIds: string[], + registryAddresses: string[], + vcAndDiscloseCircuitVerifiers: string[], + registerCircuitVerifierIds: bigint[], + registerCircuitVerifiers: string[], + dscCircuitVerifierIds: bigint[], + dscCircuitVerifiers: string[] + ]; + export interface OutputObject { + attestationIds: string[]; + registryAddresses: string[]; + vcAndDiscloseCircuitVerifiers: string[]; + registerCircuitVerifierIds: bigint[]; + registerCircuitVerifiers: string[]; + dscCircuitVerifierIds: bigint[]; + dscCircuitVerifiers: string[]; + } + export type Event = TypedContractEvent; + export type Filter = TypedDeferredTopicFilter; + export type Log = TypedEventLog; + export type LogDescription = TypedLogDescription; +} + +export namespace InitializedEvent { + export type InputTuple = [version: BigNumberish]; + export type OutputTuple = [version: bigint]; + export interface OutputObject { + version: bigint; + } + export type Event = TypedContractEvent; + export type Filter = TypedDeferredTopicFilter; + export type Log = TypedEventLog; + export type LogDescription = TypedLogDescription; +} + +export namespace OwnershipTransferStartedEvent { + export type InputTuple = [previousOwner: AddressLike, newOwner: AddressLike]; + export type OutputTuple = [previousOwner: string, newOwner: string]; + export interface OutputObject { + previousOwner: string; + newOwner: string; + } + export type Event = TypedContractEvent; + export type Filter = TypedDeferredTopicFilter; + export type Log = TypedEventLog; + export type LogDescription = TypedLogDescription; +} + +export namespace OwnershipTransferredEvent { + export type InputTuple = [previousOwner: AddressLike, newOwner: AddressLike]; + export type OutputTuple = [previousOwner: string, newOwner: string]; + export interface OutputObject { + previousOwner: string; + newOwner: string; + } + export type Event = TypedContractEvent; + export type Filter = TypedDeferredTopicFilter; + export type Log = TypedEventLog; + export type LogDescription = TypedLogDescription; +} + +export namespace RegisterCircuitVerifierUpdatedEvent { + export type InputTuple = [typeId: BigNumberish, verifier: AddressLike]; + export type OutputTuple = [typeId: bigint, verifier: string]; + export interface OutputObject { + typeId: bigint; + verifier: string; + } + export type Event = TypedContractEvent; + export type Filter = TypedDeferredTopicFilter; + export type Log = TypedEventLog; + export type LogDescription = TypedLogDescription; +} + +export namespace RegistryUpdatedEvent { + export type InputTuple = [attestationId: BytesLike, registry: AddressLike]; + export type OutputTuple = [attestationId: string, registry: string]; + export interface OutputObject { + attestationId: string; + registry: string; + } + export type Event = TypedContractEvent; + export type Filter = TypedDeferredTopicFilter; + export type Log = TypedEventLog; + export type LogDescription = TypedLogDescription; +} + +export namespace UpgradedEvent { + export type InputTuple = [implementation: AddressLike]; + export type OutputTuple = [implementation: string]; + export interface OutputObject { + implementation: string; + } + export type Event = TypedContractEvent; + export type Filter = TypedDeferredTopicFilter; + export type Log = TypedEventLog; + export type LogDescription = TypedLogDescription; +} + +export namespace VcAndDiscloseCircuitUpdatedEvent { + export type InputTuple = [ + attestationId: BytesLike, + vcAndDiscloseCircuitVerifier: AddressLike + ]; + export type OutputTuple = [ + attestationId: string, + vcAndDiscloseCircuitVerifier: string + ]; + export interface OutputObject { + attestationId: string; + vcAndDiscloseCircuitVerifier: string; + } + export type Event = TypedContractEvent; + export type Filter = TypedDeferredTopicFilter; + export type Log = TypedEventLog; + export type LogDescription = TypedLogDescription; +} + +export interface IdentityVerificationHubImpl extends BaseContract { + connect(runner?: ContractRunner | null): IdentityVerificationHubImpl; + waitForDeployment(): Promise; + + interface: IdentityVerificationHubImplInterface; + + queryFilter( + event: TCEvent, + fromBlockOrBlockhash?: string | number | undefined, + toBlock?: string | number | undefined + ): Promise>>; + queryFilter( + filter: TypedDeferredTopicFilter, + fromBlockOrBlockhash?: string | number | undefined, + toBlock?: string | number | undefined + ): Promise>>; + + on( + event: TCEvent, + listener: TypedListener + ): Promise; + on( + filter: TypedDeferredTopicFilter, + listener: TypedListener + ): Promise; + + once( + event: TCEvent, + listener: TypedListener + ): Promise; + once( + filter: TypedDeferredTopicFilter, + listener: TypedListener + ): Promise; + + listeners( + event: TCEvent + ): Promise>>; + listeners(eventName?: string): Promise>; + removeAllListeners( + event?: TCEvent + ): Promise; + + UPGRADE_INTERFACE_VERSION: TypedContractMethod<[], [string], "view">; + + acceptOwnership: TypedContractMethod<[], [void], "nonpayable">; + + batchUpdateDscCircuitVerifiers: TypedContractMethod< + [typeIds: BigNumberish[], verifierAddresses: AddressLike[]], + [void], + "nonpayable" + >; + + batchUpdateRegisterCircuitVerifiers: TypedContractMethod< + [typeIds: BigNumberish[], verifierAddresses: AddressLike[]], + [void], + "nonpayable" + >; + + initialize: TypedContractMethod< + [ + attestationIds: BytesLike[], + registryAddresses: AddressLike[], + vcAndDiscloseCircuitVerifierAddresses: AddressLike[], + registerCircuitVerifierIds: BigNumberish[], + registerCircuitVerifierAddresses: AddressLike[], + dscCircuitVerifierIds: BigNumberish[], + dscCircuitVerifierAddresses: AddressLike[] + ], + [void], + "nonpayable" + >; + + owner: TypedContractMethod<[], [string], "view">; + + pendingOwner: TypedContractMethod<[], [string], "view">; + + proxiableUUID: TypedContractMethod<[], [string], "view">; + + registerCommitment: TypedContractMethod< + [ + attestationId: BytesLike, + registerCircuitVerifierId: BigNumberish, + registerCircuitProof: IRegisterCircuitVerifier.RegisterCircuitProofStruct + ], + [void], + "nonpayable" + >; + + registerDscKeyCommitment: TypedContractMethod< + [ + attestationId: BytesLike, + dscCircuitVerifierId: BigNumberish, + dscCircuitProof: IDscCircuitVerifier.DscCircuitProofStruct + ], + [void], + "nonpayable" + >; + + registry: TypedContractMethod<[attestationId: BytesLike], [string], "view">; + + renounceOwnership: TypedContractMethod<[], [void], "nonpayable">; + + sigTypeToDscCircuitVerifiers: TypedContractMethod< + [typeId: BigNumberish], + [string], + "view" + >; + + sigTypeToRegisterCircuitVerifiers: TypedContractMethod< + [typeId: BigNumberish], + [string], + "view" + >; + + transferOwnership: TypedContractMethod< + [newOwner: AddressLike], + [void], + "nonpayable" + >; + + updateDscVerifier: TypedContractMethod< + [typeId: BigNumberish, verifierAddress: AddressLike], + [void], + "nonpayable" + >; + + updateRegisterCircuitVerifier: TypedContractMethod< + [typeId: BigNumberish, verifierAddress: AddressLike], + [void], + "nonpayable" + >; + + updateRegistry: TypedContractMethod< + [attestationId: BytesLike, registryAddress: AddressLike], + [void], + "nonpayable" + >; + + updateVcAndDiscloseCircuit: TypedContractMethod< + [ + attestationId: BytesLike, + vcAndDiscloseCircuitVerifierAddress: AddressLike + ], + [void], + "nonpayable" + >; + + upgradeToAndCall: TypedContractMethod< + [newImplementation: AddressLike, data: BytesLike], + [void], + "payable" + >; + + vcAndDiscloseCircuitVerifier: TypedContractMethod< + [attestationId: BytesLike], + [string], + "view" + >; + + verifyVcAndDisclose: TypedContractMethod< + [proofData: BytesLike], + [string], + "view" + >; + + getFunction( + key: string | FunctionFragment + ): T; + + getFunction( + nameOrSignature: "UPGRADE_INTERFACE_VERSION" + ): TypedContractMethod<[], [string], "view">; + getFunction( + nameOrSignature: "acceptOwnership" + ): TypedContractMethod<[], [void], "nonpayable">; + getFunction( + nameOrSignature: "batchUpdateDscCircuitVerifiers" + ): TypedContractMethod< + [typeIds: BigNumberish[], verifierAddresses: AddressLike[]], + [void], + "nonpayable" + >; + getFunction( + nameOrSignature: "batchUpdateRegisterCircuitVerifiers" + ): TypedContractMethod< + [typeIds: BigNumberish[], verifierAddresses: AddressLike[]], + [void], + "nonpayable" + >; + getFunction( + nameOrSignature: "initialize" + ): TypedContractMethod< + [ + attestationIds: BytesLike[], + registryAddresses: AddressLike[], + vcAndDiscloseCircuitVerifierAddresses: AddressLike[], + registerCircuitVerifierIds: BigNumberish[], + registerCircuitVerifierAddresses: AddressLike[], + dscCircuitVerifierIds: BigNumberish[], + dscCircuitVerifierAddresses: AddressLike[] + ], + [void], + "nonpayable" + >; + getFunction( + nameOrSignature: "owner" + ): TypedContractMethod<[], [string], "view">; + getFunction( + nameOrSignature: "pendingOwner" + ): TypedContractMethod<[], [string], "view">; + getFunction( + nameOrSignature: "proxiableUUID" + ): TypedContractMethod<[], [string], "view">; + getFunction( + nameOrSignature: "registerCommitment" + ): TypedContractMethod< + [ + attestationId: BytesLike, + registerCircuitVerifierId: BigNumberish, + registerCircuitProof: IRegisterCircuitVerifier.RegisterCircuitProofStruct + ], + [void], + "nonpayable" + >; + getFunction( + nameOrSignature: "registerDscKeyCommitment" + ): TypedContractMethod< + [ + attestationId: BytesLike, + dscCircuitVerifierId: BigNumberish, + dscCircuitProof: IDscCircuitVerifier.DscCircuitProofStruct + ], + [void], + "nonpayable" + >; + getFunction( + nameOrSignature: "registry" + ): TypedContractMethod<[attestationId: BytesLike], [string], "view">; + getFunction( + nameOrSignature: "renounceOwnership" + ): TypedContractMethod<[], [void], "nonpayable">; + getFunction( + nameOrSignature: "sigTypeToDscCircuitVerifiers" + ): TypedContractMethod<[typeId: BigNumberish], [string], "view">; + getFunction( + nameOrSignature: "sigTypeToRegisterCircuitVerifiers" + ): TypedContractMethod<[typeId: BigNumberish], [string], "view">; + getFunction( + nameOrSignature: "transferOwnership" + ): TypedContractMethod<[newOwner: AddressLike], [void], "nonpayable">; + getFunction( + nameOrSignature: "updateDscVerifier" + ): TypedContractMethod< + [typeId: BigNumberish, verifierAddress: AddressLike], + [void], + "nonpayable" + >; + getFunction( + nameOrSignature: "updateRegisterCircuitVerifier" + ): TypedContractMethod< + [typeId: BigNumberish, verifierAddress: AddressLike], + [void], + "nonpayable" + >; + getFunction( + nameOrSignature: "updateRegistry" + ): TypedContractMethod< + [attestationId: BytesLike, registryAddress: AddressLike], + [void], + "nonpayable" + >; + getFunction( + nameOrSignature: "updateVcAndDiscloseCircuit" + ): TypedContractMethod< + [ + attestationId: BytesLike, + vcAndDiscloseCircuitVerifierAddress: AddressLike + ], + [void], + "nonpayable" + >; + getFunction( + nameOrSignature: "upgradeToAndCall" + ): TypedContractMethod< + [newImplementation: AddressLike, data: BytesLike], + [void], + "payable" + >; + getFunction( + nameOrSignature: "vcAndDiscloseCircuitVerifier" + ): TypedContractMethod<[attestationId: BytesLike], [string], "view">; + getFunction( + nameOrSignature: "verifyVcAndDisclose" + ): TypedContractMethod<[proofData: BytesLike], [string], "view">; + + getEvent( + key: "DscCircuitVerifierUpdated" + ): TypedContractEvent< + DscCircuitVerifierUpdatedEvent.InputTuple, + DscCircuitVerifierUpdatedEvent.OutputTuple, + DscCircuitVerifierUpdatedEvent.OutputObject + >; + getEvent( + key: "HubInitialized" + ): TypedContractEvent< + HubInitializedEvent.InputTuple, + HubInitializedEvent.OutputTuple, + HubInitializedEvent.OutputObject + >; + getEvent( + key: "Initialized" + ): TypedContractEvent< + InitializedEvent.InputTuple, + InitializedEvent.OutputTuple, + InitializedEvent.OutputObject + >; + getEvent( + key: "OwnershipTransferStarted" + ): TypedContractEvent< + OwnershipTransferStartedEvent.InputTuple, + OwnershipTransferStartedEvent.OutputTuple, + OwnershipTransferStartedEvent.OutputObject + >; + getEvent( + key: "OwnershipTransferred" + ): TypedContractEvent< + OwnershipTransferredEvent.InputTuple, + OwnershipTransferredEvent.OutputTuple, + OwnershipTransferredEvent.OutputObject + >; + getEvent( + key: "RegisterCircuitVerifierUpdated" + ): TypedContractEvent< + RegisterCircuitVerifierUpdatedEvent.InputTuple, + RegisterCircuitVerifierUpdatedEvent.OutputTuple, + RegisterCircuitVerifierUpdatedEvent.OutputObject + >; + getEvent( + key: "RegistryUpdated" + ): TypedContractEvent< + RegistryUpdatedEvent.InputTuple, + RegistryUpdatedEvent.OutputTuple, + RegistryUpdatedEvent.OutputObject + >; + getEvent( + key: "Upgraded" + ): TypedContractEvent< + UpgradedEvent.InputTuple, + UpgradedEvent.OutputTuple, + UpgradedEvent.OutputObject + >; + getEvent( + key: "VcAndDiscloseCircuitUpdated" + ): TypedContractEvent< + VcAndDiscloseCircuitUpdatedEvent.InputTuple, + VcAndDiscloseCircuitUpdatedEvent.OutputTuple, + VcAndDiscloseCircuitUpdatedEvent.OutputObject + >; + + filters: { + "DscCircuitVerifierUpdated(uint256,address)": TypedContractEvent< + DscCircuitVerifierUpdatedEvent.InputTuple, + DscCircuitVerifierUpdatedEvent.OutputTuple, + DscCircuitVerifierUpdatedEvent.OutputObject + >; + DscCircuitVerifierUpdated: TypedContractEvent< + DscCircuitVerifierUpdatedEvent.InputTuple, + DscCircuitVerifierUpdatedEvent.OutputTuple, + DscCircuitVerifierUpdatedEvent.OutputObject + >; + + "HubInitialized(bytes32[],address[],address[],uint256[],address[],uint256[],address[])": TypedContractEvent< + HubInitializedEvent.InputTuple, + HubInitializedEvent.OutputTuple, + HubInitializedEvent.OutputObject + >; + HubInitialized: TypedContractEvent< + HubInitializedEvent.InputTuple, + HubInitializedEvent.OutputTuple, + HubInitializedEvent.OutputObject + >; + + "Initialized(uint64)": TypedContractEvent< + InitializedEvent.InputTuple, + InitializedEvent.OutputTuple, + InitializedEvent.OutputObject + >; + Initialized: TypedContractEvent< + InitializedEvent.InputTuple, + InitializedEvent.OutputTuple, + InitializedEvent.OutputObject + >; + + "OwnershipTransferStarted(address,address)": TypedContractEvent< + OwnershipTransferStartedEvent.InputTuple, + OwnershipTransferStartedEvent.OutputTuple, + OwnershipTransferStartedEvent.OutputObject + >; + OwnershipTransferStarted: TypedContractEvent< + OwnershipTransferStartedEvent.InputTuple, + OwnershipTransferStartedEvent.OutputTuple, + OwnershipTransferStartedEvent.OutputObject + >; + + "OwnershipTransferred(address,address)": TypedContractEvent< + OwnershipTransferredEvent.InputTuple, + OwnershipTransferredEvent.OutputTuple, + OwnershipTransferredEvent.OutputObject + >; + OwnershipTransferred: TypedContractEvent< + OwnershipTransferredEvent.InputTuple, + OwnershipTransferredEvent.OutputTuple, + OwnershipTransferredEvent.OutputObject + >; + + "RegisterCircuitVerifierUpdated(uint256,address)": TypedContractEvent< + RegisterCircuitVerifierUpdatedEvent.InputTuple, + RegisterCircuitVerifierUpdatedEvent.OutputTuple, + RegisterCircuitVerifierUpdatedEvent.OutputObject + >; + RegisterCircuitVerifierUpdated: TypedContractEvent< + RegisterCircuitVerifierUpdatedEvent.InputTuple, + RegisterCircuitVerifierUpdatedEvent.OutputTuple, + RegisterCircuitVerifierUpdatedEvent.OutputObject + >; + + "RegistryUpdated(bytes32,address)": TypedContractEvent< + RegistryUpdatedEvent.InputTuple, + RegistryUpdatedEvent.OutputTuple, + RegistryUpdatedEvent.OutputObject + >; + RegistryUpdated: TypedContractEvent< + RegistryUpdatedEvent.InputTuple, + RegistryUpdatedEvent.OutputTuple, + RegistryUpdatedEvent.OutputObject + >; + + "Upgraded(address)": TypedContractEvent< + UpgradedEvent.InputTuple, + UpgradedEvent.OutputTuple, + UpgradedEvent.OutputObject + >; + Upgraded: TypedContractEvent< + UpgradedEvent.InputTuple, + UpgradedEvent.OutputTuple, + UpgradedEvent.OutputObject + >; + + "VcAndDiscloseCircuitUpdated(bytes32,address)": TypedContractEvent< + VcAndDiscloseCircuitUpdatedEvent.InputTuple, + VcAndDiscloseCircuitUpdatedEvent.OutputTuple, + VcAndDiscloseCircuitUpdatedEvent.OutputObject + >; + VcAndDiscloseCircuitUpdated: TypedContractEvent< + VcAndDiscloseCircuitUpdatedEvent.InputTuple, + VcAndDiscloseCircuitUpdatedEvent.OutputTuple, + VcAndDiscloseCircuitUpdatedEvent.OutputObject + >; + }; +} diff --git a/sdk/core/src/typechain-types/common.ts b/sdk/core/src/typechain-types/common.ts new file mode 100644 index 000000000..56b5f21e9 --- /dev/null +++ b/sdk/core/src/typechain-types/common.ts @@ -0,0 +1,131 @@ +/* Autogenerated file. Do not edit manually. */ +/* tslint:disable */ +/* eslint-disable */ +import type { + FunctionFragment, + Typed, + EventFragment, + ContractTransaction, + ContractTransactionResponse, + DeferredTopicFilter, + EventLog, + TransactionRequest, + LogDescription, +} from "ethers"; + +export interface TypedDeferredTopicFilter<_TCEvent extends TypedContractEvent> + extends DeferredTopicFilter {} + +export interface TypedContractEvent< + InputTuple extends Array = any, + OutputTuple extends Array = any, + OutputObject = any +> { + (...args: Partial): TypedDeferredTopicFilter< + TypedContractEvent + >; + name: string; + fragment: EventFragment; + getFragment(...args: Partial): EventFragment; +} + +type __TypechainAOutputTuple = T extends TypedContractEvent< + infer _U, + infer W +> + ? W + : never; +type __TypechainOutputObject = T extends TypedContractEvent< + infer _U, + infer _W, + infer V +> + ? V + : never; + +export interface TypedEventLog + extends Omit { + args: __TypechainAOutputTuple & __TypechainOutputObject; +} + +export interface TypedLogDescription + extends Omit { + args: __TypechainAOutputTuple & __TypechainOutputObject; +} + +export type TypedListener = ( + ...listenerArg: [ + ...__TypechainAOutputTuple, + TypedEventLog, + ...undefined[] + ] +) => void; + +export type MinEthersFactory = { + deploy(...a: ARGS[]): Promise; +}; + +export type GetContractTypeFromFactory = F extends MinEthersFactory< + infer C, + any +> + ? C + : never; +export type GetARGsTypeFromFactory = F extends MinEthersFactory + ? Parameters + : never; + +export type StateMutability = "nonpayable" | "payable" | "view"; + +export type BaseOverrides = Omit; +export type NonPayableOverrides = Omit< + BaseOverrides, + "value" | "blockTag" | "enableCcipRead" +>; +export type PayableOverrides = Omit< + BaseOverrides, + "blockTag" | "enableCcipRead" +>; +export type ViewOverrides = Omit; +export type Overrides = S extends "nonpayable" + ? NonPayableOverrides + : S extends "payable" + ? PayableOverrides + : ViewOverrides; + +export type PostfixOverrides, S extends StateMutability> = + | A + | [...A, Overrides]; +export type ContractMethodArgs< + A extends Array, + S extends StateMutability +> = PostfixOverrides<{ [I in keyof A]-?: A[I] | Typed }, S>; + +export type DefaultReturnType = R extends Array ? R[0] : R; + +// export interface ContractMethod = Array, R = any, D extends R | ContractTransactionResponse = R | ContractTransactionResponse> { +export interface TypedContractMethod< + A extends Array = Array, + R = any, + S extends StateMutability = "payable" +> { + (...args: ContractMethodArgs): S extends "view" + ? Promise> + : Promise; + + name: string; + + fragment: FunctionFragment; + + getFragment(...args: ContractMethodArgs): FunctionFragment; + + populateTransaction( + ...args: ContractMethodArgs + ): Promise; + staticCall( + ...args: ContractMethodArgs + ): Promise>; + send(...args: ContractMethodArgs): Promise; + estimateGas(...args: ContractMethodArgs): Promise; + staticCallResult(...args: ContractMethodArgs): Promise; +} diff --git a/sdk/core/src/typechain-types/factories/IdentityVerificationHubImpl__factory.ts b/sdk/core/src/typechain-types/factories/IdentityVerificationHubImpl__factory.ts new file mode 100644 index 000000000..619f5fd65 --- /dev/null +++ b/sdk/core/src/typechain-types/factories/IdentityVerificationHubImpl__factory.ts @@ -0,0 +1,836 @@ +/* Autogenerated file. Do not edit manually. */ +/* tslint:disable */ +/* eslint-disable */ + +import { Contract, Interface, type ContractRunner } from "ethers"; +import type { + IdentityVerificationHubImpl, + IdentityVerificationHubImplInterface, +} from "../IdentityVerificationHubImpl.js"; + +const _abi = [ + { + inputs: [], + stateMutability: "nonpayable", + type: "constructor", + }, + { + inputs: [ + { + internalType: "address", + name: "target", + type: "address", + }, + ], + name: "AddressEmptyCode", + type: "error", + }, + { + inputs: [], + name: "CURRENT_DATE_NOT_IN_VALID_RANGE", + type: "error", + }, + { + inputs: [ + { + internalType: "address", + name: "implementation", + type: "address", + }, + ], + name: "ERC1967InvalidImplementation", + type: "error", + }, + { + inputs: [], + name: "ERC1967NonPayable", + type: "error", + }, + { + inputs: [], + name: "FailedCall", + type: "error", + }, + { + inputs: [], + name: "INVALID_ATTESTATION_ID", + type: "error", + }, + { + inputs: [], + name: "INVALID_COMMITMENT_ROOT", + type: "error", + }, + { + inputs: [], + name: "INVALID_CSCA_ROOT", + type: "error", + }, + { + inputs: [], + name: "INVALID_DSC_PROOF", + type: "error", + }, + { + inputs: [], + name: "INVALID_FORBIDDEN_COUNTRIES", + type: "error", + }, + { + inputs: [], + name: "INVALID_OFAC", + type: "error", + }, + { + inputs: [], + name: "INVALID_OFAC_ROOT", + type: "error", + }, + { + inputs: [], + name: "INVALID_OLDER_THAN", + type: "error", + }, + { + inputs: [], + name: "INVALID_REGISTER_PROOF", + type: "error", + }, + { + inputs: [], + name: "INVALID_REVEALED_DATA_TYPE", + type: "error", + }, + { + inputs: [], + name: "INVALID_VC_AND_DISCLOSE_PROOF", + type: "error", + }, + { + inputs: [], + name: "InvalidDateDigit", + type: "error", + }, + { + inputs: [], + name: "InvalidDateLength", + type: "error", + }, + { + inputs: [], + name: "InvalidDayRange", + type: "error", + }, + { + inputs: [], + name: "InvalidFieldElement", + type: "error", + }, + { + inputs: [], + name: "InvalidInitialization", + type: "error", + }, + { + inputs: [], + name: "InvalidMonthRange", + type: "error", + }, + { + inputs: [], + name: "InvalidYearRange", + type: "error", + }, + { + inputs: [], + name: "LENGTH_MISMATCH", + type: "error", + }, + { + inputs: [], + name: "NO_VERIFIER_SET", + type: "error", + }, + { + inputs: [], + name: "NotInitializing", + type: "error", + }, + { + inputs: [ + { + internalType: "address", + name: "owner", + type: "address", + }, + ], + name: "OwnableInvalidOwner", + type: "error", + }, + { + inputs: [ + { + internalType: "address", + name: "account", + type: "address", + }, + ], + name: "OwnableUnauthorizedAccount", + type: "error", + }, + { + inputs: [], + name: "UUPSUnauthorizedCallContext", + type: "error", + }, + { + inputs: [ + { + internalType: "bytes32", + name: "slot", + type: "bytes32", + }, + ], + name: "UUPSUnsupportedProxiableUUID", + type: "error", + }, + { + anonymous: false, + inputs: [ + { + indexed: false, + internalType: "uint256", + name: "typeId", + type: "uint256", + }, + { + indexed: false, + internalType: "address", + name: "verifier", + type: "address", + }, + ], + name: "DscCircuitVerifierUpdated", + type: "event", + }, + { + anonymous: false, + inputs: [ + { + indexed: false, + internalType: "bytes32[]", + name: "attestationIds", + type: "bytes32[]", + }, + { + indexed: false, + internalType: "address[]", + name: "registryAddresses", + type: "address[]", + }, + { + indexed: false, + internalType: "address[]", + name: "vcAndDiscloseCircuitVerifiers", + type: "address[]", + }, + { + indexed: false, + internalType: "uint256[]", + name: "registerCircuitVerifierIds", + type: "uint256[]", + }, + { + indexed: false, + internalType: "address[]", + name: "registerCircuitVerifiers", + type: "address[]", + }, + { + indexed: false, + internalType: "uint256[]", + name: "dscCircuitVerifierIds", + type: "uint256[]", + }, + { + indexed: false, + internalType: "address[]", + name: "dscCircuitVerifiers", + type: "address[]", + }, + ], + name: "HubInitialized", + type: "event", + }, + { + anonymous: false, + inputs: [ + { + indexed: false, + internalType: "uint64", + name: "version", + type: "uint64", + }, + ], + name: "Initialized", + type: "event", + }, + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: "address", + name: "previousOwner", + type: "address", + }, + { + indexed: true, + internalType: "address", + name: "newOwner", + type: "address", + }, + ], + name: "OwnershipTransferStarted", + type: "event", + }, + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: "address", + name: "previousOwner", + type: "address", + }, + { + indexed: true, + internalType: "address", + name: "newOwner", + type: "address", + }, + ], + name: "OwnershipTransferred", + type: "event", + }, + { + anonymous: false, + inputs: [ + { + indexed: false, + internalType: "uint256", + name: "typeId", + type: "uint256", + }, + { + indexed: false, + internalType: "address", + name: "verifier", + type: "address", + }, + ], + name: "RegisterCircuitVerifierUpdated", + type: "event", + }, + { + anonymous: false, + inputs: [ + { + indexed: false, + internalType: "bytes32", + name: "attestationId", + type: "bytes32", + }, + { + indexed: false, + internalType: "address", + name: "registry", + type: "address", + }, + ], + name: "RegistryUpdated", + type: "event", + }, + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: "address", + name: "implementation", + type: "address", + }, + ], + name: "Upgraded", + type: "event", + }, + { + anonymous: false, + inputs: [ + { + indexed: false, + internalType: "bytes32", + name: "attestationId", + type: "bytes32", + }, + { + indexed: false, + internalType: "address", + name: "vcAndDiscloseCircuitVerifier", + type: "address", + }, + ], + name: "VcAndDiscloseCircuitUpdated", + type: "event", + }, + { + inputs: [], + name: "UPGRADE_INTERFACE_VERSION", + outputs: [ + { + internalType: "string", + name: "", + type: "string", + }, + ], + stateMutability: "view", + type: "function", + }, + { + inputs: [], + name: "acceptOwnership", + outputs: [], + stateMutability: "nonpayable", + type: "function", + }, + { + inputs: [ + { + internalType: "uint256[]", + name: "typeIds", + type: "uint256[]", + }, + { + internalType: "address[]", + name: "verifierAddresses", + type: "address[]", + }, + ], + name: "batchUpdateDscCircuitVerifiers", + outputs: [], + stateMutability: "nonpayable", + type: "function", + }, + { + inputs: [ + { + internalType: "uint256[]", + name: "typeIds", + type: "uint256[]", + }, + { + internalType: "address[]", + name: "verifierAddresses", + type: "address[]", + }, + ], + name: "batchUpdateRegisterCircuitVerifiers", + outputs: [], + stateMutability: "nonpayable", + type: "function", + }, + { + inputs: [ + { + internalType: "bytes32[]", + name: "attestationIds", + type: "bytes32[]", + }, + { + internalType: "address[]", + name: "registryAddresses", + type: "address[]", + }, + { + internalType: "address[]", + name: "vcAndDiscloseCircuitVerifierAddresses", + type: "address[]", + }, + { + internalType: "uint256[]", + name: "registerCircuitVerifierIds", + type: "uint256[]", + }, + { + internalType: "address[]", + name: "registerCircuitVerifierAddresses", + type: "address[]", + }, + { + internalType: "uint256[]", + name: "dscCircuitVerifierIds", + type: "uint256[]", + }, + { + internalType: "address[]", + name: "dscCircuitVerifierAddresses", + type: "address[]", + }, + ], + name: "initialize", + outputs: [], + stateMutability: "nonpayable", + type: "function", + }, + { + inputs: [], + name: "owner", + outputs: [ + { + internalType: "address", + name: "", + type: "address", + }, + ], + stateMutability: "view", + type: "function", + }, + { + inputs: [], + name: "pendingOwner", + outputs: [ + { + internalType: "address", + name: "", + type: "address", + }, + ], + stateMutability: "view", + type: "function", + }, + { + inputs: [], + name: "proxiableUUID", + outputs: [ + { + internalType: "bytes32", + name: "", + type: "bytes32", + }, + ], + stateMutability: "view", + type: "function", + }, + { + inputs: [ + { + internalType: "bytes32", + name: "attestationId", + type: "bytes32", + }, + { + internalType: "uint256", + name: "registerCircuitVerifierId", + type: "uint256", + }, + { + components: [ + { + internalType: "uint256[2]", + name: "a", + type: "uint256[2]", + }, + { + internalType: "uint256[2][2]", + name: "b", + type: "uint256[2][2]", + }, + { + internalType: "uint256[2]", + name: "c", + type: "uint256[2]", + }, + { + internalType: "uint256[3]", + name: "pubSignals", + type: "uint256[3]", + }, + ], + internalType: "struct IRegisterCircuitVerifier.RegisterCircuitProof", + name: "registerCircuitProof", + type: "tuple", + }, + ], + name: "registerCommitment", + outputs: [], + stateMutability: "nonpayable", + type: "function", + }, + { + inputs: [ + { + internalType: "bytes32", + name: "attestationId", + type: "bytes32", + }, + { + internalType: "uint256", + name: "dscCircuitVerifierId", + type: "uint256", + }, + { + components: [ + { + internalType: "uint256[2]", + name: "a", + type: "uint256[2]", + }, + { + internalType: "uint256[2][2]", + name: "b", + type: "uint256[2][2]", + }, + { + internalType: "uint256[2]", + name: "c", + type: "uint256[2]", + }, + { + internalType: "uint256[2]", + name: "pubSignals", + type: "uint256[2]", + }, + ], + internalType: "struct IDscCircuitVerifier.DscCircuitProof", + name: "dscCircuitProof", + type: "tuple", + }, + ], + name: "registerDscKeyCommitment", + outputs: [], + stateMutability: "nonpayable", + type: "function", + }, + { + inputs: [ + { + internalType: "bytes32", + name: "attestationId", + type: "bytes32", + }, + ], + name: "registry", + outputs: [ + { + internalType: "address", + name: "", + type: "address", + }, + ], + stateMutability: "view", + type: "function", + }, + { + inputs: [], + name: "renounceOwnership", + outputs: [], + stateMutability: "nonpayable", + type: "function", + }, + { + inputs: [ + { + internalType: "uint256", + name: "typeId", + type: "uint256", + }, + ], + name: "sigTypeToDscCircuitVerifiers", + outputs: [ + { + internalType: "address", + name: "", + type: "address", + }, + ], + stateMutability: "view", + type: "function", + }, + { + inputs: [ + { + internalType: "uint256", + name: "typeId", + type: "uint256", + }, + ], + name: "sigTypeToRegisterCircuitVerifiers", + outputs: [ + { + internalType: "address", + name: "", + type: "address", + }, + ], + stateMutability: "view", + type: "function", + }, + { + inputs: [ + { + internalType: "address", + name: "newOwner", + type: "address", + }, + ], + name: "transferOwnership", + outputs: [], + stateMutability: "nonpayable", + type: "function", + }, + { + inputs: [ + { + internalType: "uint256", + name: "typeId", + type: "uint256", + }, + { + internalType: "address", + name: "verifierAddress", + type: "address", + }, + ], + name: "updateDscVerifier", + outputs: [], + stateMutability: "nonpayable", + type: "function", + }, + { + inputs: [ + { + internalType: "uint256", + name: "typeId", + type: "uint256", + }, + { + internalType: "address", + name: "verifierAddress", + type: "address", + }, + ], + name: "updateRegisterCircuitVerifier", + outputs: [], + stateMutability: "nonpayable", + type: "function", + }, + { + inputs: [ + { + internalType: "bytes32", + name: "attestationId", + type: "bytes32", + }, + { + internalType: "address", + name: "registryAddress", + type: "address", + }, + ], + name: "updateRegistry", + outputs: [], + stateMutability: "nonpayable", + type: "function", + }, + { + inputs: [ + { + internalType: "bytes32", + name: "attestationId", + type: "bytes32", + }, + { + internalType: "address", + name: "vcAndDiscloseCircuitVerifierAddress", + type: "address", + }, + ], + name: "updateVcAndDiscloseCircuit", + outputs: [], + stateMutability: "nonpayable", + type: "function", + }, + { + inputs: [ + { + internalType: "address", + name: "newImplementation", + type: "address", + }, + { + internalType: "bytes", + name: "data", + type: "bytes", + }, + ], + name: "upgradeToAndCall", + outputs: [], + stateMutability: "payable", + type: "function", + }, + { + inputs: [ + { + internalType: "bytes32", + name: "attestationId", + type: "bytes32", + }, + ], + name: "vcAndDiscloseCircuitVerifier", + outputs: [ + { + internalType: "address", + name: "", + type: "address", + }, + ], + stateMutability: "view", + type: "function", + }, + { + inputs: [ + { + internalType: "bytes", + name: "proofData", + type: "bytes", + }, + ], + name: "verifyVcAndDisclose", + outputs: [ + { + internalType: "bytes", + name: "result", + type: "bytes", + }, + ], + stateMutability: "view", + type: "function", + }, +] as const; + +export class IdentityVerificationHubImpl__factory { + static readonly abi = _abi; + static createInterface(): IdentityVerificationHubImplInterface { + return new Interface(_abi) as IdentityVerificationHubImplInterface; + } + static connect( + address: string, + runner?: ContractRunner | null + ): IdentityVerificationHubImpl { + return new Contract( + address, + _abi, + runner + ) as unknown as IdentityVerificationHubImpl; + } +} diff --git a/sdk/core/src/typechain-types/factories/index.ts b/sdk/core/src/typechain-types/factories/index.ts new file mode 100644 index 000000000..d16d52dfd --- /dev/null +++ b/sdk/core/src/typechain-types/factories/index.ts @@ -0,0 +1,4 @@ +/* Autogenerated file. Do not edit manually. */ +/* tslint:disable */ +/* eslint-disable */ +export { IdentityVerificationHubImpl__factory } from "./IdentityVerificationHubImpl__factory.js"; diff --git a/sdk/core/src/typechain-types/index.ts b/sdk/core/src/typechain-types/index.ts new file mode 100644 index 000000000..49e0c61d3 --- /dev/null +++ b/sdk/core/src/typechain-types/index.ts @@ -0,0 +1,6 @@ +/* Autogenerated file. Do not edit manually. */ +/* tslint:disable */ +/* eslint-disable */ +export type { IdentityVerificationHubImpl } from "./IdentityVerificationHubImpl.js"; +export * as factories from "./factories/index.js"; +export { IdentityVerificationHubImpl__factory } from "./factories/IdentityVerificationHubImpl__factory.js"; diff --git a/sdk/core/src/types/types.ts b/sdk/core/src/types/types.ts index fcd6f3213..1807856dd 100644 --- a/sdk/core/src/types/types.ts +++ b/sdk/core/src/types/types.ts @@ -6,3 +6,8 @@ export type VcAndDiscloseProof = { c: [BigNumberish, BigNumberish]; pubSignals: BigNumberish[]; }; + +// export type VerificationConfig = + +interface IConfigStorage { +} diff --git a/yarn.lock b/yarn.lock index 27d5a9385..21dbc03a9 100644 --- a/yarn.lock +++ b/yarn.lock @@ -4310,7 +4310,7 @@ __metadata: "@selfxyz/common@file:../../common::locator=%40selfxyz%2Fcore%40workspace%3Asdk%2Fcore": version: 0.0.2 - resolution: "@selfxyz/common@file:../../common#../../common::hash=50993d&locator=%40selfxyz%2Fcore%40workspace%3Asdk%2Fcore" + resolution: "@selfxyz/common@file:../../common#../../common::hash=c4cbd1&locator=%40selfxyz%2Fcore%40workspace%3Asdk%2Fcore" dependencies: "@openpassport/zk-kit-imt": "npm:^0.0.5" "@openpassport/zk-kit-lean-imt": "npm:^0.0.6" @@ -4337,7 +4337,7 @@ __metadata: snarkjs: "npm:^0.7.5" typescript-parser: "npm:^2.6.1" uuid: "npm:^11.0.5" - checksum: 10c0/ed038945ad93e4424658f7cb1fb421696c3c5ececd653a53ec00df592edd5c48ab2e4ea9bb431f032ad9d964a19a417569ff6c6709bbc672dc215b10c60e1b30 + checksum: 10c0/78ab1198944837f4726a467ccbe02133ce86ed5435980a997fe2c51f1c0261c48dfc03c5ddca23755060d7cd2df9d00d07f16dc14ad4bc2ec54ecf9966385aad languageName: node linkType: hard @@ -4437,6 +4437,7 @@ __metadata: resolution: "@selfxyz/core@workspace:sdk/core" dependencies: "@selfxyz/common": "file:../../common" + "@typechain/ethers-v6": "npm:^0.5.1" "@types/chai": "npm:^4.3.6" "@types/chai-as-promised": "npm:^7.1.8" "@types/circomlibjs": "npm:^0.1.6" @@ -4459,6 +4460,7 @@ __metadata: ts-loader: "npm:^9.5.1" ts-node: "npm:^10.9.2" tsup: "npm:^8.5.0" + typechain: "npm:^8.3.2" typescript: "npm:^5.4.5" uuid: "npm:^11.1.0" languageName: unknown @@ -7861,6 +7863,20 @@ __metadata: languageName: node linkType: hard +"@typechain/ethers-v6@npm:^0.5.1": + version: 0.5.1 + resolution: "@typechain/ethers-v6@npm:0.5.1" + dependencies: + lodash: "npm:^4.17.15" + ts-essentials: "npm:^7.0.1" + peerDependencies: + ethers: 6.x + typechain: ^8.3.2 + typescript: ">=4.7.0" + checksum: 10c0/f3c80151c07e01adbf520e0854426649edb0ee540920569487dd8da7eca2fa8615710f4c0eda008e7afdf255fbb8dfdebf721a5d324a4dffeb087611d9bd64b9 + languageName: node + linkType: hard + "@typechain/hardhat@npm:^8.0.3": version: 8.0.3 resolution: "@typechain/hardhat@npm:8.0.3" From 28aaa76e3dd58203c7c45235430d58336bbe2fce Mon Sep 17 00:00:00 2001 From: Ayman Date: Thu, 19 Jun 2025 17:38:19 +0530 Subject: [PATCH 03/25] feat: add custom verification --- sdk/core/index.ts | 2 - sdk/core/package.json | 3 +- sdk/core/src/SelfBackendVerifier.ts | 458 ++--- sdk/core/src/abi/IdentityRegistryImplV1.ts | 1228 ------------ .../src/abi/IdentityVerificationHubImpl.json | 1778 +++++++++-------- sdk/core/src/abi/Registry.json | 30 + sdk/core/src/abi/Verifier.json | 36 + sdk/core/src/abi/VerifyAll.ts | 294 --- sdk/core/src/constants/contractAddresses.ts | 4 - sdk/core/src/errors.ts | 44 + sdk/core/src/store/DefaultConfigStore.ts | 19 + sdk/core/src/store/interface.ts | 23 + .../IdentityVerificationHubImpl.ts | 402 ++-- sdk/core/src/typechain-types/Registry.ts | 95 + sdk/core/src/typechain-types/Verifier.ts | 114 ++ .../IdentityVerificationHubImpl__factory.ts | 389 ++-- .../factories/Registry__factory.ts | 38 + .../factories/Verifier__factory.ts | 53 + .../src/typechain-types/factories/index.ts | 2 + sdk/core/src/typechain-types/index.ts | 4 + sdk/core/src/types/types.ts | 6 +- sdk/core/src/utils/constants.ts | 75 + sdk/core/src/utils/hash.ts | 9 + sdk/core/src/utils/id.ts | 48 + sdk/core/src/utils/proof.ts | 42 + sdk/core/src/utils/utils.ts | 52 +- 26 files changed, 2401 insertions(+), 2847 deletions(-) delete mode 100644 sdk/core/src/abi/IdentityRegistryImplV1.ts create mode 100644 sdk/core/src/abi/Registry.json create mode 100644 sdk/core/src/abi/Verifier.json delete mode 100644 sdk/core/src/abi/VerifyAll.ts delete mode 100644 sdk/core/src/constants/contractAddresses.ts create mode 100644 sdk/core/src/errors.ts create mode 100644 sdk/core/src/store/DefaultConfigStore.ts create mode 100644 sdk/core/src/store/interface.ts create mode 100644 sdk/core/src/typechain-types/Registry.ts create mode 100644 sdk/core/src/typechain-types/Verifier.ts create mode 100644 sdk/core/src/typechain-types/factories/Registry__factory.ts create mode 100644 sdk/core/src/typechain-types/factories/Verifier__factory.ts create mode 100644 sdk/core/src/utils/constants.ts create mode 100644 sdk/core/src/utils/hash.ts create mode 100644 sdk/core/src/utils/id.ts create mode 100644 sdk/core/src/utils/proof.ts diff --git a/sdk/core/index.ts b/sdk/core/index.ts index 6ac7826b0..a49ec7db8 100644 --- a/sdk/core/index.ts +++ b/sdk/core/index.ts @@ -1,5 +1,4 @@ import { SelfBackendVerifier } from './src/SelfBackendVerifier.js'; -import { getUserIdentifier } from './src/utils/utils.js'; import { countryCodes } from '@selfxyz/common/constants/constants'; import { getUniversalLink, SelfAppBuilder } from '@selfxyz/common/utils/appType'; export type { SelfApp } from '@selfxyz/common/utils/appType'; @@ -9,7 +8,6 @@ import { getPackedForbiddenCountries } from '@selfxyz/common/utils/contracts/for export { SelfBackendVerifier, - getUserIdentifier, countryCodes, getUniversalLink, countries, diff --git a/sdk/core/package.json b/sdk/core/package.json index 0b88d17a6..199028ddb 100644 --- a/sdk/core/package.json +++ b/sdk/core/package.json @@ -28,6 +28,7 @@ ], "scripts": { "build": "tsup index.ts --format cjs,esm --dts --clean --sourcemap", + "build:deps": "yarn workspaces foreach --from @selfxyz/core --topological-dev --recursive run build", "copy-abi": "bash scripts/copyAbi.sh", "format": "prettier --write .", "install-sdk": "yarn workspaces focus @selfxyz/core", @@ -37,7 +38,7 @@ "types": "yarn build" }, "dependencies": { - "@selfxyz/common": "file:../../common", + "@selfxyz/common": "workspace:^", "@types/uuid": "^10.0.0", "ethers": "^6.13.5", "js-sha1": "^0.7.0", diff --git a/sdk/core/src/SelfBackendVerifier.ts b/sdk/core/src/SelfBackendVerifier.ts index 6ed1ef556..bd5aa545e 100644 --- a/sdk/core/src/SelfBackendVerifier.ts +++ b/sdk/core/src/SelfBackendVerifier.ts @@ -1,285 +1,259 @@ import { ethers } from 'ethers'; import { hashEndpointWithScope } from '@selfxyz/common/utils/scope'; -import { IdentityVerificationHubImpl, IdentityVerificationHubImpl__factory } from './typechain-types/index.js'; +import { IdentityVerificationHubImpl, IdentityVerificationHubImpl__factory, Registry__factory, Verifier, Verifier__factory } from './typechain-types/index.js'; +import { AttestationId, discloseIndices } from './utils/constants.js'; +import { formatRevealedDataPacked } from './utils/id.js'; +import { VcAndDiscloseProof } from './types/types.js'; +import { Country3LetterCode } from '@selfxyz/common'; +import { calculateUserIdentifierHash } from './utils/hash.js'; +import { castToUserIdentifier, UserIdType } from '@selfxyz/common/utils/circuits/uuid'; +import { ConfigMismatch, ConfigMismatchError, InvalidProof, InvalidProofError } from './errors.js'; +import { DefaultConfigStore } from './store/DefaultConfigStore.js'; +import { IConfigStorage } from './store/interface.js'; +import { unpackForbiddenCountriesList } from './utils/utils.js'; const CELO_MAINNET_RPC_URL = 'https://forno.celo.org'; const CELO_TESTNET_RPC_URL = 'https://alfajores-forno.celo-testnet.org'; const IDENTITY_VERIFICATION_HUB_ADDRESS = '0x0000000000000000000000000000000000000000'; -const IDENTITY_VERIFICATION_HUB_ADDRESS_STAGING = '0x0000000000000000000000000000000000000000'; +const IDENTITY_VERIFICATION_HUB_ADDRESS_STAGING = '0xb32424e64810Ffa264155419C8D898B838715E47'; export class SelfBackendVerifier { protected scope: string; protected identityVerificationHubContract: IdentityVerificationHubImpl; - protected configStorage; + protected configStorage: IConfigStorage; + protected provider: ethers.JsonRpcProvider; + protected allowedIds: Map; + protected userIdentifierType: UserIdType; - constructor(scope: string, endpoint: string, mockPassport: boolean = false) { + constructor(scope: string, endpoint: string, mockPassport: boolean = false, allowedIds: Map, configStorage: IConfigStorage, userIdentifierType: UserIdType) { const rpcUrl = mockPassport ? CELO_TESTNET_RPC_URL : CELO_MAINNET_RPC_URL; const provider = new ethers.JsonRpcProvider(rpcUrl); const identityVerificationHubAddress = mockPassport ? IDENTITY_VERIFICATION_HUB_ADDRESS_STAGING : IDENTITY_VERIFICATION_HUB_ADDRESS; this.identityVerificationHubContract = IdentityVerificationHubImpl__factory.connect(identityVerificationHubAddress, provider); + this.provider = provider; this.scope = hashEndpointWithScope(endpoint, scope); + this.allowedIds = allowedIds; + this.configStorage = configStorage; + this.userIdentifierType = userIdentifierType; } -} - -// export class SelfBackendVerifier { -// protected scope: string; -// protected attestationId: number = 1; -// protected user_identifier_type: UserIdType = 'uuid'; -// protected targetRootTimestamp: { enabled: boolean; value: number } = { -// enabled: false, -// value: 0, -// }; - -// protected nationality: { -// enabled: boolean; -// value: Country3LetterCode; -// } = { -// enabled: false, -// value: '' as Country3LetterCode, -// }; -// protected minimumAge: { enabled: boolean; value: string } = { -// enabled: false, -// value: '18', -// }; -// protected excludedCountries: { -// enabled: boolean; -// value: Country3LetterCode[]; -// } = { -// enabled: false, -// value: [], -// }; -// protected passportNoOfac: boolean = false; -// protected nameAndDobOfac: boolean = false; -// protected nameAndYobOfac: boolean = false; -// protected registryContract: ethers.Contract; -// protected verifyAllContract: ethers.Contract; -// protected mockPassport: boolean; + public async verify( + attestationId: AttestationId, + proof: VcAndDiscloseProof, + userContextData: string, + ) { + //check if attestation id is allowed + const allowedId = this.allowedIds.get(attestationId); + let issues: Array<{ type: ConfigMismatch; message: string }> = []; + if (!allowedId) { + issues.push({ type: ConfigMismatch.InvalidId, message: 'Attestation ID is not allowed' }); + } -// constructor( -// scope: string, -// endpoint: string, -// user_identifier_type: UserIdType = 'uuid', -// mockPassport: boolean = false -// ) { -// const rpcUrl = mockPassport ? CELO_TESTNET_RPC_URL : CELO_MAINNET_RPC_URL; -// const provider = new ethers.JsonRpcProvider(rpcUrl); -// const registryAddress = mockPassport ? REGISTRY_ADDRESS_STAGING : REGISTRY_ADDRESS; -// const verifyAllAddress = mockPassport ? VERIFYALL_ADDRESS_STAGING : VERIFYALL_ADDRESS; -// this.registryContract = new ethers.Contract(registryAddress, registryAbi, provider); -// this.verifyAllContract = new ethers.Contract(verifyAllAddress, verifyAllAbi, provider); -// this.scope = hashEndpointWithScope(endpoint, scope); -// this.user_identifier_type = user_identifier_type; -// this.mockPassport = mockPassport; -// } + const publicSignals = proof.pubSignals.map(String).map((x) => /[a-f]/g.test(x) ? '0x' + x : x); -// public async verify(proof: any, publicSignals: PublicSignals): Promise { -// const forbiddenCountriesListPacked = packForbiddenCountriesList(this.excludedCountries.value); + //check if user context hash matches + const userContextHashInCircuit = publicSignals[discloseIndices[attestationId].userIdentifierIndex]; + const userContextHash = calculateUserIdentifierHash(userContextData); -// const isValidScope = -// this.scope === publicSignals[CIRCUIT_CONSTANTS.VC_AND_DISCLOSE_SCOPE_INDEX]; + if (userContextHashInCircuit !== userContextHash) { + issues.push({ type: ConfigMismatch.InvalidUserContextHash, message: 'User context hash does not match with the one in the circuit' }); + } -// const isValidAttestationId = -// this.attestationId.toString() === -// publicSignals[CIRCUIT_CONSTANTS.VC_AND_DISCLOSE_ATTESTATION_ID_INDEX]; + //check if scope matches + const isValidScope = this.scope === publicSignals[discloseIndices[attestationId].scopeIndex]; + if (!isValidScope) { + issues.push({ type: ConfigMismatch.InvalidScope, message: 'Scope does not match with the one in the circuit' }); + } -// const vcAndDiscloseHubProof = { -// olderThanEnabled: this.minimumAge.enabled, -// olderThan: this.minimumAge.value, -// forbiddenCountriesEnabled: this.excludedCountries.enabled, -// forbiddenCountriesListPacked: forbiddenCountriesListPacked, -// ofacEnabled: [this.passportNoOfac, this.nameAndDobOfac, this.nameAndYobOfac], -// vcAndDiscloseProof: { -// a: proof.a, -// b: [ -// [proof.b[0][1], proof.b[0][0]], -// [proof.b[1][1], proof.b[1][0]], -// ], -// c: proof.c, -// pubSignals: publicSignals, -// }, -// }; + //check the root + try { + const registryAddress = await this.identityVerificationHubContract.registry('0x' + attestationId.toString(16).padStart(64, '0')); + if (registryAddress === '0x0000000000000000000000000000000000000000') { + throw new Error('Registry contract not found'); + } + console.log('registryAddress', registryAddress); + const registryContract = Registry__factory.connect(registryAddress, this.provider); + console.log('publicSignals[discloseIndices[attestationId].merkleRootIndex]', publicSignals[discloseIndices[attestationId].merkleRootIndex]); + const currentRoot = await registryContract.checkIdentityCommitmentRoot(publicSignals[discloseIndices[attestationId].merkleRootIndex]); + if (!currentRoot) { + issues.push({ type: ConfigMismatch.InvalidRoot, message: 'Onchain root does not match with the one in the circuit' }); + } + } catch (error) { + throw new Error('Registry contract not found'); + } -// const types = [ -// revealedDataTypes.issuing_state, -// revealedDataTypes.name, -// revealedDataTypes.passport_number, -// revealedDataTypes.nationality, -// revealedDataTypes.date_of_birth, -// revealedDataTypes.gender, -// revealedDataTypes.expiry_date, -// ]; + //check if attestation id matches + const isValidAttestationId = attestationId.toString() === publicSignals[discloseIndices[attestationId].attestationIdIndex]; + if (!isValidAttestationId) { + issues.push({ type: ConfigMismatch.InvalidAttestationId, message: 'Attestation ID does not match with the one in the circuit' }); + } -// if (this.minimumAge.enabled) { -// types.push(revealedDataTypes.older_than); -// } + const userIdentifier = castToUserIdentifier(BigInt(userContextData.slice(0, 32)), this.userIdentifierType); + const userDefinedData = userContextData.slice(32); + const configId = await this.configStorage.getActionId(userIdentifier, userDefinedData); + const verificationConfig = await this.configStorage.getConfig(configId); -// if (this.passportNoOfac) { -// types.push(revealedDataTypes.passport_no_ofac); -// } + //check if forbidden countries list matches + const forbiddenCountriesList = unpackForbiddenCountriesList(verificationConfig.forbiddenCountriesListPacked.map(String)); + const forbiddenCountriesListVerificationConfig = unpackForbiddenCountriesList(verificationConfig.forbiddenCountriesListPacked.map(String)); -// if (this.nameAndDobOfac) { -// types.push(revealedDataTypes.name_and_dob_ofac); -// } + const isForbiddenCountryListValid = forbiddenCountriesListVerificationConfig.every(country => forbiddenCountriesList.includes(country as Country3LetterCode)); + if (!isForbiddenCountryListValid) { + issues.push({ type: ConfigMismatch.InvalidForbiddenCountriesList, message: 'Forbidden countries list in config does not match with the one in the circuit' }); + } -// if (this.nameAndYobOfac) { -// types.push(revealedDataTypes.name_and_yob_ofac); -// } + const genericDiscloseOutput = formatRevealedDataPacked(attestationId, publicSignals); + //check if minimum age matches + const isMinimumAgeValid = verificationConfig.olderThanEnabled ? verificationConfig.olderThan === genericDiscloseOutput.olderThan : true; + if (!isMinimumAgeValid) { + issues.push({ type: ConfigMismatch.InvalidMinimumAge, message: 'Minimum age in config does not match with the one in the circuit' }); + } -// const currentRoot = await this.registryContract.getIdentityCommitmentMerkleRoot(); -// const timestamp = await this.registryContract.rootTimestamps(currentRoot); + const circuitTimestampYy = [2, 0, publicSignals[discloseIndices[attestationId].currentDateIndex], publicSignals[discloseIndices[attestationId].currentDateIndex + 1]]; + const circuitTimestampMm = [publicSignals[discloseIndices[attestationId].currentDateIndex + 2], publicSignals[discloseIndices[attestationId].currentDateIndex + 3]]; + const circuitTimestampDd = [publicSignals[discloseIndices[attestationId].currentDateIndex + 4], publicSignals[discloseIndices[attestationId].currentDateIndex + 5]]; + const circuitTimestamp = new Date(Number(circuitTimestampYy.join('')), Number(circuitTimestampMm.join('')) - 1, Number(circuitTimestampDd.join(''))); + const currentTimestamp = new Date(); -// const user_identifier = castToUserIdentifier( -// BigInt(publicSignals[CIRCUIT_CONSTANTS.VC_AND_DISCLOSE_USER_IDENTIFIER_INDEX]), -// this.user_identifier_type -// ); + //check if timestamp is in the future + if (circuitTimestamp > currentTimestamp) { + issues.push({ type: ConfigMismatch.InvalidTimestamp, message: 'Circuit timestamp is in the future' }); + } -// let result: any; -// try { -// result = await this.verifyAllContract.verifyAll(timestamp, vcAndDiscloseHubProof, types); -// } catch (error: any) { -// let errorMessage = error instanceof Error ? error.message : 'Unknown error'; -// if ( -// error && -// typeof error === 'object' && -// error.message && -// error.message.includes('INVALID_FORBIDDEN_COUNTRIES') -// ) { -// errorMessage = -// 'The forbidden countries list in the backend does not match the list provided in the frontend SDK. Please ensure both lists are identical.'; -// } + //check if timestamp is 1 day in the past + currentTimestamp.setTime(currentTimestamp.getTime() - (24 * 60 * 60 * 1000)); + if (circuitTimestamp < currentTimestamp) { + issues.push({ type: ConfigMismatch.InvalidTimestamp, message: 'Circuit timestamp is too old' }); + } -// return { -// isValid: false, -// isValidDetails: { -// isValidScope: false, -// isValidAttestationId: false, -// isValidProof: false, -// isValidNationality: false, -// }, -// userId: user_identifier, -// application: this.scope, -// nullifier: publicSignals[CIRCUIT_CONSTANTS.VC_AND_DISCLOSE_NULLIFIER_INDEX], -// credentialSubject: {}, -// proof: { -// value: { -// proof: proof, -// publicSignals: publicSignals, -// }, -// }, -// error: errorMessage, -// }; -// } + if (!verificationConfig.ofacEnabled[0] && genericDiscloseOutput.ofac[0]) { + issues.push({ type: ConfigMismatch.InvalidOfac, message: 'Passport number OFAC check is not allowed' }); + } -// let isValidNationality = true; -// if (this.nationality.enabled) { -// const nationality = result[0][revealedDataTypes.nationality]; -// isValidNationality = nationality === this.nationality.value; -// } + if (!verificationConfig.ofacEnabled[1] && genericDiscloseOutput.ofac[1]) { + issues.push({ type: ConfigMismatch.InvalidOfac, message: 'Name and DOB OFAC check is not allowed' }); + } -// const credentialSubject = { -// merkle_root: publicSignals[CIRCUIT_CONSTANTS.VC_AND_DISCLOSE_MERKLE_ROOT_INDEX], -// attestation_id: this.attestationId.toString(), -// current_date: new Date().toISOString(), -// issuing_state: result[0][revealedDataTypes.issuing_state], -// name: result[0][revealedDataTypes.name], -// passport_number: result[0][revealedDataTypes.passport_number], -// nationality: result[0][revealedDataTypes.nationality], -// date_of_birth: result[0][revealedDataTypes.date_of_birth], -// gender: result[0][revealedDataTypes.gender], -// expiry_date: result[0][revealedDataTypes.expiry_date], -// older_than: result[0][revealedDataTypes.older_than].toString(), -// passport_no_ofac: result[0][revealedDataTypes.passport_no_ofac].toString() === '1', -// name_and_dob_ofac: result[0][revealedDataTypes.name_and_dob_ofac].toString() === '1', -// name_and_yob_ofac: result[0][revealedDataTypes.name_and_yob_ofac].toString() === '1', -// }; + if (!verificationConfig.ofacEnabled[2] && genericDiscloseOutput.ofac[2]) { + issues.push({ type: ConfigMismatch.InvalidOfac, message: 'Name and YOB OFAC check is not allowed' }); + } -// const attestation: SelfVerificationResult = { -// isValid: result[1] && isValidScope && isValidAttestationId && isValidNationality, -// isValidDetails: { -// isValidScope: isValidScope, -// isValidAttestationId: isValidAttestationId, -// isValidProof: result[1], -// isValidNationality: isValidNationality, -// }, -// userId: user_identifier, -// application: this.scope, -// nullifier: publicSignals[CIRCUIT_CONSTANTS.VC_AND_DISCLOSE_NULLIFIER_INDEX], -// credentialSubject: credentialSubject, -// proof: { -// value: { -// proof: proof, -// publicSignals: publicSignals, -// }, -// }, -// error: result[2], -// }; + if (issues.length > 0) { + throw new ConfigMismatchError(issues); + } -// return attestation; -// } + let verifierContract: Verifier; + try { + const verifierAddress = await this.identityVerificationHubContract.discloseVerifier('0x' + attestationId.toString(16).padStart(64, '0')); + verifierContract = Verifier__factory.connect(verifierAddress, this.provider); + console.log('verifierAddress', verifierAddress); + }catch (error) { + throw new Error('Verifier contract not found'); + } -// setMinimumAge(age: number): this { -// if (age <= 0) { -// throw new Error('Minimum age must be positive'); -// } -// if (age > 100) { -// throw new Error('Minimum age must be at most 100 years old'); -// } -// this.minimumAge = { enabled: true, value: age.toString() }; -// return this; -// } + const isValid = await verifierContract.verifyProof(proof.a, [ + [proof.b[0][1], proof.b[0][0]], + [proof.b[1][1], proof.b[1][0]], + ], proof.c, publicSignals); -// setNationality(country: Country3LetterCode): this { -// this.nationality = { enabled: true, value: country }; -// return this; -// } + if (!isValid) { + throw new InvalidProofError(InvalidProof.InvalidProof, 'Proof is invalid'); + } -// /** -// * Sets the list of countries to be excluded in the verification. -// * This list must exactly match the list configured in the backend. -// * -// * @param countries Array of 3-letter country codes to exclude -// * @returns This instance for method chaining -// * @throws Error if more than 40 countries are provided or if any country code is invalid -// */ -// excludeCountries(...countries: Country3LetterCode[]): this { -// if (countries.length > 40) { -// throw new Error('Number of excluded countries cannot exceed 40'); -// } -// // Validate country codes -// for (const country of countries) { -// if (!country || country.length !== 3) { -// throw new Error( -// `Invalid country code: "${country}". Country codes must be exactly 3 characters long.` -// ); -// } -// // Check if the country code exists in the list of valid codes (additional check) -// const isValidCountry = Object.values(commonNames).some( -// (name) => name === country || country in commonNames -// ); -// if (!isValidCountry) { -// throw new Error( -// `Unknown country code: "${country}". Please use valid 3-letter ISO country codes.` -// ); -// } -// } -// this.excludedCountries = { enabled: true, value: countries }; -// return this; -// } + return { + isValid, + discloseOutput: genericDiscloseOutput, + userIdentifier, + userDefinedData, + isOlderThanValid: verificationConfig.olderThanEnabled ? verificationConfig.olderThan <= genericDiscloseOutput.olderThan : true, + isForbiddenCountriesListValid: verificationConfig.forbiddenCountriesEnabled ? forbiddenCountriesList.includes(genericDiscloseOutput.nationality) : true, + isOfacValid: verificationConfig.ofacEnabled.every((enabled, index) => enabled ? genericDiscloseOutput.ofac[index] : true), + } + } +} -// enablePassportNoOfacCheck(): this { -// this.passportNoOfac = true; -// return this; -// } +(async () => { + const allowedIds = new Map(); + allowedIds.set(1, true); + allowedIds.set(2, true); + const verifier = new SelfBackendVerifier('https://selfxyz.io', 'https://selfxyz.io', true, allowedIds, new DefaultConfigStore({ + olderThanEnabled: false, + olderThan: '18', + forbiddenCountriesEnabled: false, + forbiddenCountriesListPacked: [ + '0x414754414154414149414f4741444e414d5341415a44424c41414c41474641', + '0x4542524c42425242444742524842534842455a415355415742414d52414752', + '0x4e41434d484b5650434e52424c4f424e5442554d424e45425a4c42554d424c', + '0x4853454d4559424d5a45575a5455564b4e445453454e4843564943' + ], + ofacEnabled: [true, true, true] + }), 'uuid'); -// enableNameAndDobOfacCheck(): this { -// this.nameAndDobOfac = true; -// return this; -// } + // await verifier.verify(1, { + // "a": ["20027747457384548915754048546300078359238644739611306732203396740377022269632", "2922252454334934814523912619336295865418779710963506663844841070040892368599"], + // "b": [ + // ["18550618272017193017683281599041714361177883341207882150042864009452803287635", "11835322382845835127938425066445170832745075061887634147517477198658857275684"], + // ["9589052941833010873145632477110100396776386222278078408779066519235765125504", "4446299920668248986575867643716084694453281451335382773821734541324874380964"]], + // "c": ["13869518253907120487751576221202706397626340056519243861474381557882676036567", "12690387074286053910397617351082313207917428545513560875234502132363926637665"], + // pubSignals: [ + // "0", + // "104974056514807040022473273876258729896969411582978218858119168", + // "1773781688717606310397756023428205332782362187156068670010833396561870848", + // "6818352527182560077653388211384938507686473", + // "0", + // "0", + // "0", + // "8393865390816338643283234268763358234972139160362896016192609318836495598412", + // "1", + // "12042122855944027015224247589071180050575929049407085527795781545283481922120", + // "2", + // "5", + // "0", + // "6", + // "1", + // "5", + // "17359956125106148146828355805271472653597249114301196742546733402427978706344", + // "7420120618403967585712321281997181302561301414016003514649937965499789236588", + // "16836358042995742879630198413873414945978677264752036026400967422611478610995", + // "20547922292487865646889398151624351195094737616498816569824986876525492837134", + // "32484638221990080388773097521078796272" + // ]}, + // "1234567890" + // ); -// enableNameAndYobOfacCheck(): this { -// this.nameAndYobOfac = true; -// return this; -// } -// } + await verifier.verify(2, + { + "a": ["12081211863281045519638435814320218331506181778260003189006684934781096301530", "8060260813032756056355953005294591165747245129871184047363247350832615678279"], + "b": [ + ["4347315068897320978820992945813773246810792668754558635019200272564387822377", "15752614222213378619781143491974874432941718433078511349040538945306489946483"], + ["21556638492815180585049800142968980107901950444515421443099323631356046322632", "3164272229051284860567978678792807807073207139807100212958388224608073319238"] + ], + "c": ["5267406348608997194371334102763008174473847620068385896652634372612077418468", "14110837162069354172999846461488917221179735837657004699809342354383332253012"], + pubSignals: [ + "0", + "22229121118744123602918790561256186052608", + "2154665897585346283029582512769695903067754219393865093262281634727591936", + "1", + "a6818352527182560077653388211384938507686473", + "0", + "0", + "0", + "12816268866992348722154762391251116294707511988403581258809971144485079648161", + "2", + "4473515946166166681112263978860717654366030938166274938260019677592087803375", + "2", + "5", + "0", + "6", + "1", + "7", + "20550865940766091336114076617084411967227963708544788410483208672684333597871", + "20607501071671444315195585339157145490348308593668944037177822930025980459166", + "13934606664243914063643606771911468856671016933765586820821710153612586828695", + "185590350843347269691547707205927446533" + ] + }, + "1234567890" + ); +})(); diff --git a/sdk/core/src/abi/IdentityRegistryImplV1.ts b/sdk/core/src/abi/IdentityRegistryImplV1.ts deleted file mode 100644 index a11e4960f..000000000 --- a/sdk/core/src/abi/IdentityRegistryImplV1.ts +++ /dev/null @@ -1,1228 +0,0 @@ -export const registryAbi = [ - { - inputs: [], - stateMutability: 'nonpayable', - type: 'constructor', - }, - { - inputs: [ - { - internalType: 'address', - name: 'target', - type: 'address', - }, - ], - name: 'AddressEmptyCode', - type: 'error', - }, - { - inputs: [ - { - internalType: 'address', - name: 'implementation', - type: 'address', - }, - ], - name: 'ERC1967InvalidImplementation', - type: 'error', - }, - { - inputs: [], - name: 'ERC1967NonPayable', - type: 'error', - }, - { - inputs: [], - name: 'FailedCall', - type: 'error', - }, - { - inputs: [], - name: 'HUB_NOT_SET', - type: 'error', - }, - { - inputs: [], - name: 'InvalidInitialization', - type: 'error', - }, - { - inputs: [], - name: 'LeafAlreadyExists', - type: 'error', - }, - { - inputs: [], - name: 'LeafCannotBeZero', - type: 'error', - }, - { - inputs: [], - name: 'LeafDoesNotExist', - type: 'error', - }, - { - inputs: [], - name: 'LeafGreaterThanSnarkScalarField', - type: 'error', - }, - { - inputs: [], - name: 'NotInitializing', - type: 'error', - }, - { - inputs: [], - name: 'ONLY_HUB_CAN_ACCESS', - type: 'error', - }, - { - inputs: [ - { - internalType: 'address', - name: 'owner', - type: 'address', - }, - ], - name: 'OwnableInvalidOwner', - type: 'error', - }, - { - inputs: [ - { - internalType: 'address', - name: 'account', - type: 'address', - }, - ], - name: 'OwnableUnauthorizedAccount', - type: 'error', - }, - { - inputs: [], - name: 'REGISTERED_COMMITMENT', - type: 'error', - }, - { - inputs: [], - name: 'UUPSUnauthorizedCallContext', - type: 'error', - }, - { - inputs: [ - { - internalType: 'bytes32', - name: 'slot', - type: 'bytes32', - }, - ], - name: 'UUPSUnsupportedProxiableUUID', - type: 'error', - }, - { - inputs: [], - name: 'WrongSiblingNodes', - type: 'error', - }, - { - anonymous: false, - inputs: [ - { - indexed: true, - internalType: 'bytes32', - name: 'attestationId', - type: 'bytes32', - }, - { - indexed: true, - internalType: 'uint256', - name: 'nullifier', - type: 'uint256', - }, - { - indexed: true, - internalType: 'uint256', - name: 'commitment', - type: 'uint256', - }, - { - indexed: false, - internalType: 'uint256', - name: 'timestamp', - type: 'uint256', - }, - { - indexed: false, - internalType: 'uint256', - name: 'imtRoot', - type: 'uint256', - }, - { - indexed: false, - internalType: 'uint256', - name: 'imtIndex', - type: 'uint256', - }, - ], - name: 'CommitmentRegistered', - type: 'event', - }, - { - anonymous: false, - inputs: [ - { - indexed: false, - internalType: 'uint256', - name: 'cscaRoot', - type: 'uint256', - }, - ], - name: 'CscaRootUpdated', - type: 'event', - }, - { - anonymous: false, - inputs: [ - { - indexed: true, - internalType: 'bytes32', - name: 'attestationId', - type: 'bytes32', - }, - { - indexed: true, - internalType: 'uint256', - name: 'nullifier', - type: 'uint256', - }, - { - indexed: true, - internalType: 'uint256', - name: 'commitment', - type: 'uint256', - }, - { - indexed: false, - internalType: 'uint256', - name: 'timestamp', - type: 'uint256', - }, - { - indexed: false, - internalType: 'uint256', - name: 'imtRoot', - type: 'uint256', - }, - { - indexed: false, - internalType: 'uint256', - name: 'imtIndex', - type: 'uint256', - }, - ], - name: 'DevCommitmentRegistered', - type: 'event', - }, - { - anonymous: false, - inputs: [ - { - indexed: true, - internalType: 'uint256', - name: 'oldLeaf', - type: 'uint256', - }, - { - indexed: false, - internalType: 'uint256', - name: 'imtRoot', - type: 'uint256', - }, - { - indexed: false, - internalType: 'uint256', - name: 'timestamp', - type: 'uint256', - }, - ], - name: 'DevCommitmentRemoved', - type: 'event', - }, - { - anonymous: false, - inputs: [ - { - indexed: true, - internalType: 'uint256', - name: 'oldLeaf', - type: 'uint256', - }, - { - indexed: true, - internalType: 'uint256', - name: 'newLeaf', - type: 'uint256', - }, - { - indexed: false, - internalType: 'uint256', - name: 'imtRoot', - type: 'uint256', - }, - { - indexed: false, - internalType: 'uint256', - name: 'timestamp', - type: 'uint256', - }, - ], - name: 'DevCommitmentUpdated', - type: 'event', - }, - { - anonymous: false, - inputs: [ - { - indexed: true, - internalType: 'uint256', - name: 'commitment', - type: 'uint256', - }, - { - indexed: false, - internalType: 'uint256', - name: 'imtRoot', - type: 'uint256', - }, - { - indexed: false, - internalType: 'uint256', - name: 'imtIndex', - type: 'uint256', - }, - ], - name: 'DevDscKeyCommitmentRegistered', - type: 'event', - }, - { - anonymous: false, - inputs: [ - { - indexed: true, - internalType: 'uint256', - name: 'oldLeaf', - type: 'uint256', - }, - { - indexed: false, - internalType: 'uint256', - name: 'imtRoot', - type: 'uint256', - }, - ], - name: 'DevDscKeyCommitmentRemoved', - type: 'event', - }, - { - anonymous: false, - inputs: [ - { - indexed: true, - internalType: 'uint256', - name: 'commitment', - type: 'uint256', - }, - { - indexed: false, - internalType: 'bool', - name: 'state', - type: 'bool', - }, - ], - name: 'DevDscKeyCommitmentStateChanged', - type: 'event', - }, - { - anonymous: false, - inputs: [ - { - indexed: true, - internalType: 'uint256', - name: 'oldLeaf', - type: 'uint256', - }, - { - indexed: true, - internalType: 'uint256', - name: 'newLeaf', - type: 'uint256', - }, - { - indexed: false, - internalType: 'uint256', - name: 'imtRoot', - type: 'uint256', - }, - ], - name: 'DevDscKeyCommitmentUpdated', - type: 'event', - }, - { - anonymous: false, - inputs: [ - { - indexed: true, - internalType: 'bytes32', - name: 'attestationId', - type: 'bytes32', - }, - { - indexed: true, - internalType: 'uint256', - name: 'nullifier', - type: 'uint256', - }, - { - indexed: false, - internalType: 'bool', - name: 'state', - type: 'bool', - }, - ], - name: 'DevNullifierStateChanged', - type: 'event', - }, - { - anonymous: false, - inputs: [ - { - indexed: true, - internalType: 'uint256', - name: 'commitment', - type: 'uint256', - }, - { - indexed: false, - internalType: 'uint256', - name: 'timestamp', - type: 'uint256', - }, - { - indexed: false, - internalType: 'uint256', - name: 'imtRoot', - type: 'uint256', - }, - { - indexed: false, - internalType: 'uint256', - name: 'imtIndex', - type: 'uint256', - }, - ], - name: 'DscKeyCommitmentRegistered', - type: 'event', - }, - { - anonymous: false, - inputs: [ - { - indexed: false, - internalType: 'address', - name: 'hub', - type: 'address', - }, - ], - name: 'HubUpdated', - type: 'event', - }, - { - anonymous: false, - inputs: [ - { - indexed: false, - internalType: 'uint64', - name: 'version', - type: 'uint64', - }, - ], - name: 'Initialized', - type: 'event', - }, - { - anonymous: false, - inputs: [ - { - indexed: false, - internalType: 'uint256', - name: 'nameAndDobOfacRoot', - type: 'uint256', - }, - ], - name: 'NameAndDobOfacRootUpdated', - type: 'event', - }, - { - anonymous: false, - inputs: [ - { - indexed: false, - internalType: 'uint256', - name: 'nameAndYobOfacRoot', - type: 'uint256', - }, - ], - name: 'NameAndYobOfacRootUpdated', - type: 'event', - }, - { - anonymous: false, - inputs: [ - { - indexed: true, - internalType: 'address', - name: 'previousOwner', - type: 'address', - }, - { - indexed: true, - internalType: 'address', - name: 'newOwner', - type: 'address', - }, - ], - name: 'OwnershipTransferStarted', - type: 'event', - }, - { - anonymous: false, - inputs: [ - { - indexed: true, - internalType: 'address', - name: 'previousOwner', - type: 'address', - }, - { - indexed: true, - internalType: 'address', - name: 'newOwner', - type: 'address', - }, - ], - name: 'OwnershipTransferred', - type: 'event', - }, - { - anonymous: false, - inputs: [ - { - indexed: false, - internalType: 'uint256', - name: 'passportNoOfacRoot', - type: 'uint256', - }, - ], - name: 'PassportNoOfacRootUpdated', - type: 'event', - }, - { - anonymous: false, - inputs: [ - { - indexed: false, - internalType: 'address', - name: 'hub', - type: 'address', - }, - ], - name: 'RegistryInitialized', - type: 'event', - }, - { - anonymous: false, - inputs: [ - { - indexed: true, - internalType: 'address', - name: 'implementation', - type: 'address', - }, - ], - name: 'Upgraded', - type: 'event', - }, - { - inputs: [], - name: 'UPGRADE_INTERFACE_VERSION', - outputs: [ - { - internalType: 'string', - name: '', - type: 'string', - }, - ], - stateMutability: 'view', - type: 'function', - }, - { - inputs: [], - name: 'acceptOwnership', - outputs: [], - stateMutability: 'nonpayable', - type: 'function', - }, - { - inputs: [ - { - internalType: 'uint256', - name: 'root', - type: 'uint256', - }, - ], - name: 'checkCscaRoot', - outputs: [ - { - internalType: 'bool', - name: '', - type: 'bool', - }, - ], - stateMutability: 'view', - type: 'function', - }, - { - inputs: [ - { - internalType: 'uint256', - name: 'root', - type: 'uint256', - }, - ], - name: 'checkDscKeyCommitmentMerkleRoot', - outputs: [ - { - internalType: 'bool', - name: '', - type: 'bool', - }, - ], - stateMutability: 'view', - type: 'function', - }, - { - inputs: [ - { - internalType: 'uint256', - name: 'root', - type: 'uint256', - }, - ], - name: 'checkIdentityCommitmentRoot', - outputs: [ - { - internalType: 'bool', - name: '', - type: 'bool', - }, - ], - stateMutability: 'view', - type: 'function', - }, - { - inputs: [ - { - internalType: 'uint256', - name: 'passportNoRoot', - type: 'uint256', - }, - { - internalType: 'uint256', - name: 'nameAndDobRoot', - type: 'uint256', - }, - { - internalType: 'uint256', - name: 'nameAndYobRoot', - type: 'uint256', - }, - ], - name: 'checkOfacRoots', - outputs: [ - { - internalType: 'bool', - name: '', - type: 'bool', - }, - ], - stateMutability: 'view', - type: 'function', - }, - { - inputs: [ - { - internalType: 'uint256', - name: 'dscCommitment', - type: 'uint256', - }, - ], - name: 'devAddDscKeyCommitment', - outputs: [], - stateMutability: 'nonpayable', - type: 'function', - }, - { - inputs: [ - { - internalType: 'bytes32', - name: 'attestationId', - type: 'bytes32', - }, - { - internalType: 'uint256', - name: 'nullifier', - type: 'uint256', - }, - { - internalType: 'uint256', - name: 'commitment', - type: 'uint256', - }, - ], - name: 'devAddIdentityCommitment', - outputs: [], - stateMutability: 'nonpayable', - type: 'function', - }, - { - inputs: [ - { - internalType: 'uint256', - name: 'dscCommitment', - type: 'uint256', - }, - { - internalType: 'bool', - name: 'state', - type: 'bool', - }, - ], - name: 'devChangeDscKeyCommitmentState', - outputs: [], - stateMutability: 'nonpayable', - type: 'function', - }, - { - inputs: [ - { - internalType: 'bytes32', - name: 'attestationId', - type: 'bytes32', - }, - { - internalType: 'uint256', - name: 'nullifier', - type: 'uint256', - }, - { - internalType: 'bool', - name: 'state', - type: 'bool', - }, - ], - name: 'devChangeNullifierState', - outputs: [], - stateMutability: 'nonpayable', - type: 'function', - }, - { - inputs: [ - { - internalType: 'uint256', - name: 'oldLeaf', - type: 'uint256', - }, - { - internalType: 'uint256[]', - name: 'siblingNodes', - type: 'uint256[]', - }, - ], - name: 'devRemoveCommitment', - outputs: [], - stateMutability: 'nonpayable', - type: 'function', - }, - { - inputs: [ - { - internalType: 'uint256', - name: 'oldLeaf', - type: 'uint256', - }, - { - internalType: 'uint256[]', - name: 'siblingNodes', - type: 'uint256[]', - }, - ], - name: 'devRemoveDscKeyCommitment', - outputs: [], - stateMutability: 'nonpayable', - type: 'function', - }, - { - inputs: [ - { - internalType: 'uint256', - name: 'oldLeaf', - type: 'uint256', - }, - { - internalType: 'uint256', - name: 'newLeaf', - type: 'uint256', - }, - { - internalType: 'uint256[]', - name: 'siblingNodes', - type: 'uint256[]', - }, - ], - name: 'devUpdateCommitment', - outputs: [], - stateMutability: 'nonpayable', - type: 'function', - }, - { - inputs: [ - { - internalType: 'uint256', - name: 'oldLeaf', - type: 'uint256', - }, - { - internalType: 'uint256', - name: 'newLeaf', - type: 'uint256', - }, - { - internalType: 'uint256[]', - name: 'siblingNodes', - type: 'uint256[]', - }, - ], - name: 'devUpdateDscKeyCommitment', - outputs: [], - stateMutability: 'nonpayable', - type: 'function', - }, - { - inputs: [], - name: 'getCscaRoot', - outputs: [ - { - internalType: 'uint256', - name: '', - type: 'uint256', - }, - ], - stateMutability: 'view', - type: 'function', - }, - { - inputs: [ - { - internalType: 'uint256', - name: 'commitment', - type: 'uint256', - }, - ], - name: 'getDscKeyCommitmentIndex', - outputs: [ - { - internalType: 'uint256', - name: '', - type: 'uint256', - }, - ], - stateMutability: 'view', - type: 'function', - }, - { - inputs: [], - name: 'getDscKeyCommitmentMerkleRoot', - outputs: [ - { - internalType: 'uint256', - name: '', - type: 'uint256', - }, - ], - stateMutability: 'view', - type: 'function', - }, - { - inputs: [], - name: 'getDscKeyCommitmentTreeSize', - outputs: [ - { - internalType: 'uint256', - name: '', - type: 'uint256', - }, - ], - stateMutability: 'view', - type: 'function', - }, - { - inputs: [ - { - internalType: 'uint256', - name: 'commitment', - type: 'uint256', - }, - ], - name: 'getIdentityCommitmentIndex', - outputs: [ - { - internalType: 'uint256', - name: '', - type: 'uint256', - }, - ], - stateMutability: 'view', - type: 'function', - }, - { - inputs: [], - name: 'getIdentityCommitmentMerkleRoot', - outputs: [ - { - internalType: 'uint256', - name: '', - type: 'uint256', - }, - ], - stateMutability: 'view', - type: 'function', - }, - { - inputs: [], - name: 'getIdentityCommitmentMerkleTreeSize', - outputs: [ - { - internalType: 'uint256', - name: '', - type: 'uint256', - }, - ], - stateMutability: 'view', - type: 'function', - }, - { - inputs: [], - name: 'getNameAndDobOfacRoot', - outputs: [ - { - internalType: 'uint256', - name: '', - type: 'uint256', - }, - ], - stateMutability: 'view', - type: 'function', - }, - { - inputs: [], - name: 'getNameAndYobOfacRoot', - outputs: [ - { - internalType: 'uint256', - name: '', - type: 'uint256', - }, - ], - stateMutability: 'view', - type: 'function', - }, - { - inputs: [], - name: 'getPassportNoOfacRoot', - outputs: [ - { - internalType: 'uint256', - name: '', - type: 'uint256', - }, - ], - stateMutability: 'view', - type: 'function', - }, - { - inputs: [], - name: 'hub', - outputs: [ - { - internalType: 'address', - name: '', - type: 'address', - }, - ], - stateMutability: 'view', - type: 'function', - }, - { - inputs: [ - { - internalType: 'address', - name: '_hub', - type: 'address', - }, - ], - name: 'initialize', - outputs: [], - stateMutability: 'nonpayable', - type: 'function', - }, - { - inputs: [ - { - internalType: 'uint256', - name: 'commitment', - type: 'uint256', - }, - ], - name: 'isRegisteredDscKeyCommitment', - outputs: [ - { - internalType: 'bool', - name: '', - type: 'bool', - }, - ], - stateMutability: 'view', - type: 'function', - }, - { - inputs: [ - { - internalType: 'bytes32', - name: 'attestationId', - type: 'bytes32', - }, - { - internalType: 'uint256', - name: 'nullifier', - type: 'uint256', - }, - ], - name: 'nullifiers', - outputs: [ - { - internalType: 'bool', - name: '', - type: 'bool', - }, - ], - stateMutability: 'view', - type: 'function', - }, - { - inputs: [], - name: 'owner', - outputs: [ - { - internalType: 'address', - name: '', - type: 'address', - }, - ], - stateMutability: 'view', - type: 'function', - }, - { - inputs: [], - name: 'pendingOwner', - outputs: [ - { - internalType: 'address', - name: '', - type: 'address', - }, - ], - stateMutability: 'view', - type: 'function', - }, - { - inputs: [], - name: 'proxiableUUID', - outputs: [ - { - internalType: 'bytes32', - name: '', - type: 'bytes32', - }, - ], - stateMutability: 'view', - type: 'function', - }, - { - inputs: [ - { - internalType: 'bytes32', - name: 'attestationId', - type: 'bytes32', - }, - { - internalType: 'uint256', - name: 'nullifier', - type: 'uint256', - }, - { - internalType: 'uint256', - name: 'commitment', - type: 'uint256', - }, - ], - name: 'registerCommitment', - outputs: [], - stateMutability: 'nonpayable', - type: 'function', - }, - { - inputs: [ - { - internalType: 'uint256', - name: 'dscCommitment', - type: 'uint256', - }, - ], - name: 'registerDscKeyCommitment', - outputs: [], - stateMutability: 'nonpayable', - type: 'function', - }, - { - inputs: [], - name: 'renounceOwnership', - outputs: [], - stateMutability: 'nonpayable', - type: 'function', - }, - { - inputs: [ - { - internalType: 'uint256', - name: 'root', - type: 'uint256', - }, - ], - name: 'rootTimestamps', - outputs: [ - { - internalType: 'uint256', - name: '', - type: 'uint256', - }, - ], - stateMutability: 'view', - type: 'function', - }, - { - inputs: [ - { - internalType: 'address', - name: 'newOwner', - type: 'address', - }, - ], - name: 'transferOwnership', - outputs: [], - stateMutability: 'nonpayable', - type: 'function', - }, - { - inputs: [ - { - internalType: 'uint256', - name: 'newCscaRoot', - type: 'uint256', - }, - ], - name: 'updateCscaRoot', - outputs: [], - stateMutability: 'nonpayable', - type: 'function', - }, - { - inputs: [ - { - internalType: 'address', - name: 'newHubAddress', - type: 'address', - }, - ], - name: 'updateHub', - outputs: [], - stateMutability: 'nonpayable', - type: 'function', - }, - { - inputs: [ - { - internalType: 'uint256', - name: 'newNameAndDobOfacRoot', - type: 'uint256', - }, - ], - name: 'updateNameAndDobOfacRoot', - outputs: [], - stateMutability: 'nonpayable', - type: 'function', - }, - { - inputs: [ - { - internalType: 'uint256', - name: 'newNameAndYobOfacRoot', - type: 'uint256', - }, - ], - name: 'updateNameAndYobOfacRoot', - outputs: [], - stateMutability: 'nonpayable', - type: 'function', - }, - { - inputs: [ - { - internalType: 'uint256', - name: 'newPassportNoOfacRoot', - type: 'uint256', - }, - ], - name: 'updatePassportNoOfacRoot', - outputs: [], - stateMutability: 'nonpayable', - type: 'function', - }, - { - inputs: [ - { - internalType: 'address', - name: 'newImplementation', - type: 'address', - }, - { - internalType: 'bytes', - name: 'data', - type: 'bytes', - }, - ], - name: 'upgradeToAndCall', - outputs: [], - stateMutability: 'payable', - type: 'function', - }, -]; diff --git a/sdk/core/src/abi/IdentityVerificationHubImpl.json b/sdk/core/src/abi/IdentityVerificationHubImpl.json index 824389468..de2013196 100644 --- a/sdk/core/src/abi/IdentityVerificationHubImpl.json +++ b/sdk/core/src/abi/IdentityVerificationHubImpl.json @@ -1,809 +1,969 @@ -[ - { - "inputs": [], - "stateMutability": "nonpayable", - "type": "constructor" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "target", - "type": "address" - } - ], - "name": "AddressEmptyCode", - "type": "error" - }, - { - "inputs": [], - "name": "CURRENT_DATE_NOT_IN_VALID_RANGE", - "type": "error" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "implementation", - "type": "address" - } - ], - "name": "ERC1967InvalidImplementation", - "type": "error" - }, - { - "inputs": [], - "name": "ERC1967NonPayable", - "type": "error" - }, - { - "inputs": [], - "name": "FailedCall", - "type": "error" - }, - { - "inputs": [], - "name": "INVALID_ATTESTATION_ID", - "type": "error" - }, - { - "inputs": [], - "name": "INVALID_COMMITMENT_ROOT", - "type": "error" - }, - { - "inputs": [], - "name": "INVALID_CSCA_ROOT", - "type": "error" - }, - { - "inputs": [], - "name": "INVALID_DSC_PROOF", - "type": "error" - }, - { - "inputs": [], - "name": "INVALID_FORBIDDEN_COUNTRIES", - "type": "error" - }, - { - "inputs": [], - "name": "INVALID_OFAC", - "type": "error" - }, - { - "inputs": [], - "name": "INVALID_OFAC_ROOT", - "type": "error" - }, - { - "inputs": [], - "name": "INVALID_OLDER_THAN", - "type": "error" - }, - { - "inputs": [], - "name": "INVALID_REGISTER_PROOF", - "type": "error" - }, - { - "inputs": [], - "name": "INVALID_REVEALED_DATA_TYPE", - "type": "error" - }, - { - "inputs": [], - "name": "INVALID_VC_AND_DISCLOSE_PROOF", - "type": "error" - }, - { - "inputs": [], - "name": "InvalidDateDigit", - "type": "error" - }, - { - "inputs": [], - "name": "InvalidDateLength", - "type": "error" - }, - { - "inputs": [], - "name": "InvalidDayRange", - "type": "error" - }, - { - "inputs": [], - "name": "InvalidFieldElement", - "type": "error" - }, - { - "inputs": [], - "name": "InvalidInitialization", - "type": "error" - }, - { - "inputs": [], - "name": "InvalidMonthRange", - "type": "error" - }, - { - "inputs": [], - "name": "InvalidYearRange", - "type": "error" - }, - { - "inputs": [], - "name": "LENGTH_MISMATCH", - "type": "error" - }, - { - "inputs": [], - "name": "NO_VERIFIER_SET", - "type": "error" - }, - { - "inputs": [], - "name": "NotInitializing", - "type": "error" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "owner", - "type": "address" - } - ], - "name": "OwnableInvalidOwner", - "type": "error" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "account", - "type": "address" - } - ], - "name": "OwnableUnauthorizedAccount", - "type": "error" - }, - { - "inputs": [], - "name": "UUPSUnauthorizedCallContext", - "type": "error" - }, - { - "inputs": [ - { - "internalType": "bytes32", - "name": "slot", - "type": "bytes32" - } - ], - "name": "UUPSUnsupportedProxiableUUID", - "type": "error" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": false, - "internalType": "uint256", - "name": "typeId", - "type": "uint256" - }, - { - "indexed": false, - "internalType": "address", - "name": "verifier", - "type": "address" - } - ], - "name": "DscCircuitVerifierUpdated", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": false, - "internalType": "bytes32[]", - "name": "attestationIds", - "type": "bytes32[]" - }, - { - "indexed": false, - "internalType": "address[]", - "name": "registryAddresses", - "type": "address[]" - }, - { - "indexed": false, - "internalType": "address[]", - "name": "vcAndDiscloseCircuitVerifiers", - "type": "address[]" - }, - { - "indexed": false, - "internalType": "uint256[]", - "name": "registerCircuitVerifierIds", - "type": "uint256[]" - }, - { - "indexed": false, - "internalType": "address[]", - "name": "registerCircuitVerifiers", - "type": "address[]" - }, - { - "indexed": false, - "internalType": "uint256[]", - "name": "dscCircuitVerifierIds", - "type": "uint256[]" - }, - { - "indexed": false, - "internalType": "address[]", - "name": "dscCircuitVerifiers", - "type": "address[]" - } - ], - "name": "HubInitialized", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": false, - "internalType": "uint64", - "name": "version", - "type": "uint64" - } - ], - "name": "Initialized", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "address", - "name": "previousOwner", - "type": "address" - }, - { - "indexed": true, - "internalType": "address", - "name": "newOwner", - "type": "address" - } - ], - "name": "OwnershipTransferStarted", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "address", - "name": "previousOwner", - "type": "address" - }, - { - "indexed": true, - "internalType": "address", - "name": "newOwner", - "type": "address" - } - ], - "name": "OwnershipTransferred", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": false, - "internalType": "uint256", - "name": "typeId", - "type": "uint256" - }, - { - "indexed": false, - "internalType": "address", - "name": "verifier", - "type": "address" - } - ], - "name": "RegisterCircuitVerifierUpdated", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": false, - "internalType": "bytes32", - "name": "attestationId", - "type": "bytes32" - }, - { - "indexed": false, - "internalType": "address", - "name": "registry", - "type": "address" - } - ], - "name": "RegistryUpdated", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "address", - "name": "implementation", - "type": "address" - } - ], - "name": "Upgraded", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": false, - "internalType": "bytes32", - "name": "attestationId", - "type": "bytes32" - }, - { - "indexed": false, - "internalType": "address", - "name": "vcAndDiscloseCircuitVerifier", - "type": "address" - } - ], - "name": "VcAndDiscloseCircuitUpdated", - "type": "event" - }, - { - "inputs": [], - "name": "UPGRADE_INTERFACE_VERSION", - "outputs": [ - { - "internalType": "string", - "name": "", - "type": "string" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "acceptOwnership", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "uint256[]", - "name": "typeIds", - "type": "uint256[]" - }, - { - "internalType": "address[]", - "name": "verifierAddresses", - "type": "address[]" - } - ], - "name": "batchUpdateDscCircuitVerifiers", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "uint256[]", - "name": "typeIds", - "type": "uint256[]" - }, - { - "internalType": "address[]", - "name": "verifierAddresses", - "type": "address[]" - } - ], - "name": "batchUpdateRegisterCircuitVerifiers", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "bytes32[]", - "name": "attestationIds", - "type": "bytes32[]" - }, - { - "internalType": "address[]", - "name": "registryAddresses", - "type": "address[]" - }, - { - "internalType": "address[]", - "name": "vcAndDiscloseCircuitVerifierAddresses", - "type": "address[]" - }, - { - "internalType": "uint256[]", - "name": "registerCircuitVerifierIds", - "type": "uint256[]" - }, - { - "internalType": "address[]", - "name": "registerCircuitVerifierAddresses", - "type": "address[]" - }, - { - "internalType": "uint256[]", - "name": "dscCircuitVerifierIds", - "type": "uint256[]" - }, - { - "internalType": "address[]", - "name": "dscCircuitVerifierAddresses", - "type": "address[]" - } - ], - "name": "initialize", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [], - "name": "owner", - "outputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "pendingOwner", - "outputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "proxiableUUID", - "outputs": [ - { - "internalType": "bytes32", - "name": "", - "type": "bytes32" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "bytes32", - "name": "attestationId", - "type": "bytes32" - }, - { - "internalType": "uint256", - "name": "registerCircuitVerifierId", - "type": "uint256" - }, - { - "components": [ - { - "internalType": "uint256[2]", - "name": "a", - "type": "uint256[2]" - }, - { - "internalType": "uint256[2][2]", - "name": "b", - "type": "uint256[2][2]" - }, - { - "internalType": "uint256[2]", - "name": "c", - "type": "uint256[2]" - }, - { - "internalType": "uint256[3]", - "name": "pubSignals", - "type": "uint256[3]" - } - ], - "internalType": "struct IRegisterCircuitVerifier.RegisterCircuitProof", - "name": "registerCircuitProof", - "type": "tuple" - } - ], - "name": "registerCommitment", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "bytes32", - "name": "attestationId", - "type": "bytes32" - }, - { - "internalType": "uint256", - "name": "dscCircuitVerifierId", - "type": "uint256" - }, - { - "components": [ - { - "internalType": "uint256[2]", - "name": "a", - "type": "uint256[2]" - }, - { - "internalType": "uint256[2][2]", - "name": "b", - "type": "uint256[2][2]" - }, - { - "internalType": "uint256[2]", - "name": "c", - "type": "uint256[2]" - }, - { - "internalType": "uint256[2]", - "name": "pubSignals", - "type": "uint256[2]" - } - ], - "internalType": "struct IDscCircuitVerifier.DscCircuitProof", - "name": "dscCircuitProof", - "type": "tuple" - } - ], - "name": "registerDscKeyCommitment", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "bytes32", - "name": "attestationId", - "type": "bytes32" - } - ], - "name": "registry", - "outputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "renounceOwnership", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "uint256", - "name": "typeId", - "type": "uint256" - } - ], - "name": "sigTypeToDscCircuitVerifiers", - "outputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "uint256", - "name": "typeId", - "type": "uint256" - } - ], - "name": "sigTypeToRegisterCircuitVerifiers", - "outputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "newOwner", - "type": "address" - } - ], - "name": "transferOwnership", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "uint256", - "name": "typeId", - "type": "uint256" - }, - { - "internalType": "address", - "name": "verifierAddress", - "type": "address" - } - ], - "name": "updateDscVerifier", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "uint256", - "name": "typeId", - "type": "uint256" - }, - { - "internalType": "address", - "name": "verifierAddress", - "type": "address" - } - ], - "name": "updateRegisterCircuitVerifier", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "bytes32", - "name": "attestationId", - "type": "bytes32" - }, - { - "internalType": "address", - "name": "registryAddress", - "type": "address" - } - ], - "name": "updateRegistry", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "bytes32", - "name": "attestationId", - "type": "bytes32" - }, - { - "internalType": "address", - "name": "vcAndDiscloseCircuitVerifierAddress", - "type": "address" - } - ], - "name": "updateVcAndDiscloseCircuit", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "newImplementation", - "type": "address" - }, - { - "internalType": "bytes", - "name": "data", - "type": "bytes" - } - ], - "name": "upgradeToAndCall", - "outputs": [], - "stateMutability": "payable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "bytes32", - "name": "attestationId", - "type": "bytes32" - } - ], - "name": "vcAndDiscloseCircuitVerifier", - "outputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "bytes", - "name": "proofData", - "type": "bytes" - } - ], - "name": "verifyVcAndDisclose", - "outputs": [ - { - "internalType": "bytes", - "name": "result", - "type": "bytes" - } - ], - "stateMutability": "view", - "type": "function" - } -] +{ + "_format": "hh-sol-artifact-1", + "contractName": "IdentityVerificationHubImplV2", + "sourceName": "contracts/IdentityVerificationHubImplV2.sol", + "abi": [ + { + "inputs": [], + "stateMutability": "nonpayable", + "type": "constructor" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "target", + "type": "address" + } + ], + "name": "AddressEmptyCode", + "type": "error" + }, + { + "inputs": [], + "name": "CrossChainIsNotSupportedYet", + "type": "error" + }, + { + "inputs": [], + "name": "CurrentDateNotInValidRange", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "implementation", + "type": "address" + } + ], + "name": "ERC1967InvalidImplementation", + "type": "error" + }, + { + "inputs": [], + "name": "ERC1967NonPayable", + "type": "error" + }, + { + "inputs": [], + "name": "FailedCall", + "type": "error" + }, + { + "inputs": [], + "name": "InputTooShort", + "type": "error" + }, + { + "inputs": [], + "name": "InvalidAttestationId", + "type": "error" + }, + { + "inputs": [], + "name": "InvalidCscaRoot", + "type": "error" + }, + { + "inputs": [], + "name": "InvalidDateDigit", + "type": "error" + }, + { + "inputs": [], + "name": "InvalidDateLength", + "type": "error" + }, + { + "inputs": [], + "name": "InvalidDayRange", + "type": "error" + }, + { + "inputs": [], + "name": "InvalidDscCommitmentRoot", + "type": "error" + }, + { + "inputs": [], + "name": "InvalidDscProof", + "type": "error" + }, + { + "inputs": [], + "name": "InvalidFieldElement", + "type": "error" + }, + { + "inputs": [], + "name": "InvalidIdentityCommitmentRoot", + "type": "error" + }, + { + "inputs": [], + "name": "InvalidInitialization", + "type": "error" + }, + { + "inputs": [], + "name": "InvalidMonthRange", + "type": "error" + }, + { + "inputs": [], + "name": "InvalidRegisterProof", + "type": "error" + }, + { + "inputs": [], + "name": "InvalidUserIdentifierInProof", + "type": "error" + }, + { + "inputs": [], + "name": "InvalidVcAndDiscloseProof", + "type": "error" + }, + { + "inputs": [], + "name": "InvalidYearRange", + "type": "error" + }, + { + "inputs": [], + "name": "LengthMismatch", + "type": "error" + }, + { + "inputs": [], + "name": "NoVerifierSet", + "type": "error" + }, + { + "inputs": [], + "name": "NotInitializing", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "owner", + "type": "address" + } + ], + "name": "OwnableInvalidOwner", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "account", + "type": "address" + } + ], + "name": "OwnableUnauthorizedAccount", + "type": "error" + }, + { + "inputs": [], + "name": "ScopeMismatch", + "type": "error" + }, + { + "inputs": [], + "name": "UUPSUnauthorizedCallContext", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "bytes32", + "name": "slot", + "type": "bytes32" + } + ], + "name": "UUPSUnsupportedProxiableUUID", + "type": "error" + }, + { + "inputs": [], + "name": "UserContextDataTooShort", + "type": "error" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint256", + "name": "typeId", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "address", + "name": "verifier", + "type": "address" + } + ], + "name": "DscCircuitVerifierUpdated", + "type": "event" + }, + { + "anonymous": false, + "inputs": [], + "name": "HubInitializedV2", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint64", + "name": "version", + "type": "uint64" + } + ], + "name": "Initialized", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "previousOwner", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "newOwner", + "type": "address" + } + ], + "name": "OwnershipTransferStarted", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "previousOwner", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "newOwner", + "type": "address" + } + ], + "name": "OwnershipTransferred", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint256", + "name": "typeId", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "address", + "name": "verifier", + "type": "address" + } + ], + "name": "RegisterCircuitVerifierUpdated", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "bytes32", + "name": "attestationId", + "type": "bytes32" + }, + { + "indexed": false, + "internalType": "address", + "name": "registry", + "type": "address" + } + ], + "name": "RegistryUpdated", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "implementation", + "type": "address" + } + ], + "name": "Upgraded", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "bytes32", + "name": "attestationId", + "type": "bytes32" + }, + { + "indexed": false, + "internalType": "address", + "name": "vcAndDiscloseCircuitVerifier", + "type": "address" + } + ], + "name": "VcAndDiscloseCircuitUpdated", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "bytes32", + "name": "configId", + "type": "bytes32" + }, + { + "components": [ + { + "internalType": "bool", + "name": "olderThanEnabled", + "type": "bool" + }, + { + "internalType": "uint256", + "name": "olderThan", + "type": "uint256" + }, + { + "internalType": "bool", + "name": "forbiddenCountriesEnabled", + "type": "bool" + }, + { + "internalType": "uint256[4]", + "name": "forbiddenCountriesListPacked", + "type": "uint256[4]" + }, + { + "internalType": "bool[3]", + "name": "ofacEnabled", + "type": "bool[3]" + } + ], + "indexed": false, + "internalType": "struct SelfStructs.VerificationConfigV2", + "name": "config", + "type": "tuple" + } + ], + "name": "VerificationConfigV2Set", + "type": "event" + }, + { + "inputs": [], + "name": "UPGRADE_INTERFACE_VERSION", + "outputs": [ + { + "internalType": "string", + "name": "", + "type": "string" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "acceptOwnership", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes32[]", + "name": "attestationIds", + "type": "bytes32[]" + }, + { + "internalType": "uint256[]", + "name": "typeIds", + "type": "uint256[]" + }, + { + "internalType": "address[]", + "name": "verifierAddresses", + "type": "address[]" + } + ], + "name": "batchUpdateDscCircuitVerifiers", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes32[]", + "name": "attestationIds", + "type": "bytes32[]" + }, + { + "internalType": "uint256[]", + "name": "typeIds", + "type": "uint256[]" + }, + { + "internalType": "address[]", + "name": "verifierAddresses", + "type": "address[]" + } + ], + "name": "batchUpdateRegisterCircuitVerifiers", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes32", + "name": "attestationId", + "type": "bytes32" + } + ], + "name": "discloseVerifier", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes32", + "name": "attestationId", + "type": "bytes32" + }, + { + "internalType": "uint256", + "name": "typeId", + "type": "uint256" + } + ], + "name": "dscCircuitVerifiers", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "components": [ + { + "internalType": "bool", + "name": "olderThanEnabled", + "type": "bool" + }, + { + "internalType": "uint256", + "name": "olderThan", + "type": "uint256" + }, + { + "internalType": "bool", + "name": "forbiddenCountriesEnabled", + "type": "bool" + }, + { + "internalType": "uint256[4]", + "name": "forbiddenCountriesListPacked", + "type": "uint256[4]" + }, + { + "internalType": "bool[3]", + "name": "ofacEnabled", + "type": "bool[3]" + } + ], + "internalType": "struct SelfStructs.VerificationConfigV2", + "name": "config", + "type": "tuple" + } + ], + "name": "generateConfigId", + "outputs": [ + { + "internalType": "bytes32", + "name": "", + "type": "bytes32" + } + ], + "stateMutability": "pure", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes32", + "name": "attestationId", + "type": "bytes32" + } + ], + "name": "getIdentityCommitmentMerkleRoot", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "initialize", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "owner", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "pendingOwner", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "proxiableUUID", + "outputs": [ + { + "internalType": "bytes32", + "name": "", + "type": "bytes32" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes32", + "name": "attestationId", + "type": "bytes32" + }, + { + "internalType": "uint256", + "name": "typeId", + "type": "uint256" + } + ], + "name": "registerCircuitVerifiers", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes32", + "name": "attestationId", + "type": "bytes32" + }, + { + "internalType": "uint256", + "name": "registerCircuitVerifierId", + "type": "uint256" + }, + { + "components": [ + { + "internalType": "uint256[2]", + "name": "a", + "type": "uint256[2]" + }, + { + "internalType": "uint256[2][2]", + "name": "b", + "type": "uint256[2][2]" + }, + { + "internalType": "uint256[2]", + "name": "c", + "type": "uint256[2]" + }, + { + "internalType": "uint256[3]", + "name": "pubSignals", + "type": "uint256[3]" + } + ], + "internalType": "struct IRegisterCircuitVerifier.RegisterCircuitProof", + "name": "registerCircuitProof", + "type": "tuple" + } + ], + "name": "registerCommitment", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes32", + "name": "attestationId", + "type": "bytes32" + }, + { + "internalType": "uint256", + "name": "dscCircuitVerifierId", + "type": "uint256" + }, + { + "components": [ + { + "internalType": "uint256[2]", + "name": "a", + "type": "uint256[2]" + }, + { + "internalType": "uint256[2][2]", + "name": "b", + "type": "uint256[2][2]" + }, + { + "internalType": "uint256[2]", + "name": "c", + "type": "uint256[2]" + }, + { + "internalType": "uint256[2]", + "name": "pubSignals", + "type": "uint256[2]" + } + ], + "internalType": "struct IDscCircuitVerifier.DscCircuitProof", + "name": "dscCircuitProof", + "type": "tuple" + } + ], + "name": "registerDscKeyCommitment", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes32", + "name": "attestationId", + "type": "bytes32" + } + ], + "name": "registry", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "renounceOwnership", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes32", + "name": "attestationId", + "type": "bytes32" + }, + { + "internalType": "uint256", + "name": "root", + "type": "uint256" + } + ], + "name": "rootTimestamp", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "components": [ + { + "internalType": "bool", + "name": "olderThanEnabled", + "type": "bool" + }, + { + "internalType": "uint256", + "name": "olderThan", + "type": "uint256" + }, + { + "internalType": "bool", + "name": "forbiddenCountriesEnabled", + "type": "bool" + }, + { + "internalType": "uint256[4]", + "name": "forbiddenCountriesListPacked", + "type": "uint256[4]" + }, + { + "internalType": "bool[3]", + "name": "ofacEnabled", + "type": "bool[3]" + } + ], + "internalType": "struct SelfStructs.VerificationConfigV2", + "name": "config", + "type": "tuple" + } + ], + "name": "setVerificationConfigV2", + "outputs": [ + { + "internalType": "bytes32", + "name": "configId", + "type": "bytes32" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "newOwner", + "type": "address" + } + ], + "name": "transferOwnership", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes32", + "name": "attestationId", + "type": "bytes32" + }, + { + "internalType": "uint256", + "name": "typeId", + "type": "uint256" + }, + { + "internalType": "address", + "name": "verifierAddress", + "type": "address" + } + ], + "name": "updateDscVerifier", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes32", + "name": "attestationId", + "type": "bytes32" + }, + { + "internalType": "uint256", + "name": "typeId", + "type": "uint256" + }, + { + "internalType": "address", + "name": "verifierAddress", + "type": "address" + } + ], + "name": "updateRegisterCircuitVerifier", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes32", + "name": "attestationId", + "type": "bytes32" + }, + { + "internalType": "address", + "name": "registryAddress", + "type": "address" + } + ], + "name": "updateRegistry", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes32", + "name": "attestationId", + "type": "bytes32" + }, + { + "internalType": "address", + "name": "vcAndDiscloseCircuitVerifierAddress", + "type": "address" + } + ], + "name": "updateVcAndDiscloseCircuit", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "newImplementation", + "type": "address" + }, + { + "internalType": "bytes", + "name": "data", + "type": "bytes" + } + ], + "name": "upgradeToAndCall", + "outputs": [], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes32", + "name": "configId", + "type": "bytes32" + } + ], + "name": "verificationConfigV2Exists", + "outputs": [ + { + "internalType": "bool", + "name": "exists", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes", + "name": "baseVerificationInput", + "type": "bytes" + }, + { + "internalType": "bytes", + "name": "userContextData", + "type": "bytes" + } + ], + "name": "verify", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + } + ] +} diff --git a/sdk/core/src/abi/Registry.json b/sdk/core/src/abi/Registry.json new file mode 100644 index 000000000..85de289d8 --- /dev/null +++ b/sdk/core/src/abi/Registry.json @@ -0,0 +1,30 @@ +{ + "_format": "hh-sol-artifact-1", + "contractName": "IIdentityRegistryV1", + "sourceName": "contracts/interfaces/IIdentityRegistryV1.sol", + "abi": [ + { + "inputs": [ + { + "internalType": "uint256", + "name": "root", + "type": "uint256" + } + ], + "name": "checkIdentityCommitmentRoot", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + } + ], + "bytecode": "0x", + "deployedBytecode": "0x", + "linkReferences": {}, + "deployedLinkReferences": {} +} diff --git a/sdk/core/src/abi/Verifier.json b/sdk/core/src/abi/Verifier.json new file mode 100644 index 000000000..06dcce04c --- /dev/null +++ b/sdk/core/src/abi/Verifier.json @@ -0,0 +1,36 @@ +[ + { + "inputs": [ + { + "internalType": "uint256[2]", + "name": "a", + "type": "uint256[2]" + }, + { + "internalType": "uint256[2][2]", + "name": "b", + "type": "uint256[2][2]" + }, + { + "internalType": "uint256[2]", + "name": "c", + "type": "uint256[2]" + }, + { + "internalType": "uint256[21]", + "name": "pubSignals", + "type": "uint256[21]" + } + ], + "name": "verifyProof", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + } +] diff --git a/sdk/core/src/abi/VerifyAll.ts b/sdk/core/src/abi/VerifyAll.ts deleted file mode 100644 index 5b783c181..000000000 --- a/sdk/core/src/abi/VerifyAll.ts +++ /dev/null @@ -1,294 +0,0 @@ -export const verifyAllAbi = [ - { - inputs: [ - { - internalType: 'address', - name: 'hubAddress', - type: 'address', - }, - { - internalType: 'address', - name: 'registryAddress', - type: 'address', - }, - ], - stateMutability: 'nonpayable', - type: 'constructor', - }, - { - inputs: [ - { - internalType: 'address', - name: 'owner', - type: 'address', - }, - ], - name: 'OwnableInvalidOwner', - type: 'error', - }, - { - inputs: [ - { - internalType: 'address', - name: 'account', - type: 'address', - }, - ], - name: 'OwnableUnauthorizedAccount', - type: 'error', - }, - { - anonymous: false, - inputs: [ - { - indexed: true, - internalType: 'address', - name: 'previousOwner', - type: 'address', - }, - { - indexed: true, - internalType: 'address', - name: 'newOwner', - type: 'address', - }, - ], - name: 'OwnershipTransferred', - type: 'event', - }, - { - inputs: [], - name: 'hub', - outputs: [ - { - internalType: 'contract IIdentityVerificationHubV1', - name: '', - type: 'address', - }, - ], - stateMutability: 'view', - type: 'function', - }, - { - inputs: [], - name: 'owner', - outputs: [ - { - internalType: 'address', - name: '', - type: 'address', - }, - ], - stateMutability: 'view', - type: 'function', - }, - { - inputs: [], - name: 'registry', - outputs: [ - { - internalType: 'contract IIdentityRegistryV1', - name: '', - type: 'address', - }, - ], - stateMutability: 'view', - type: 'function', - }, - { - inputs: [], - name: 'renounceOwnership', - outputs: [], - stateMutability: 'nonpayable', - type: 'function', - }, - { - inputs: [ - { - internalType: 'address', - name: 'hubAddress', - type: 'address', - }, - ], - name: 'setHub', - outputs: [], - stateMutability: 'nonpayable', - type: 'function', - }, - { - inputs: [ - { - internalType: 'address', - name: 'registryAddress', - type: 'address', - }, - ], - name: 'setRegistry', - outputs: [], - stateMutability: 'nonpayable', - type: 'function', - }, - { - inputs: [ - { - internalType: 'address', - name: 'newOwner', - type: 'address', - }, - ], - name: 'transferOwnership', - outputs: [], - stateMutability: 'nonpayable', - type: 'function', - }, - { - inputs: [ - { - internalType: 'uint256', - name: 'targetRootTimestamp', - type: 'uint256', - }, - { - components: [ - { - internalType: 'bool', - name: 'olderThanEnabled', - type: 'bool', - }, - { - internalType: 'uint256', - name: 'olderThan', - type: 'uint256', - }, - { - internalType: 'bool', - name: 'forbiddenCountriesEnabled', - type: 'bool', - }, - { - internalType: 'uint256[4]', - name: 'forbiddenCountriesListPacked', - type: 'uint256[4]', - }, - { - internalType: 'bool[3]', - name: 'ofacEnabled', - type: 'bool[3]', - }, - { - components: [ - { - internalType: 'uint256[2]', - name: 'a', - type: 'uint256[2]', - }, - { - internalType: 'uint256[2][2]', - name: 'b', - type: 'uint256[2][2]', - }, - { - internalType: 'uint256[2]', - name: 'c', - type: 'uint256[2]', - }, - { - internalType: 'uint256[21]', - name: 'pubSignals', - type: 'uint256[21]', - }, - ], - internalType: 'struct IVcAndDiscloseCircuitVerifier.VcAndDiscloseProof', - name: 'vcAndDiscloseProof', - type: 'tuple', - }, - ], - internalType: 'struct IIdentityVerificationHubV1.VcAndDiscloseHubProof', - name: 'proof', - type: 'tuple', - }, - { - internalType: 'enum IIdentityVerificationHubV1.RevealedDataType[]', - name: 'types', - type: 'uint8[]', - }, - ], - name: 'verifyAll', - outputs: [ - { - components: [ - { - internalType: 'string', - name: 'issuingState', - type: 'string', - }, - { - internalType: 'string[]', - name: 'name', - type: 'string[]', - }, - { - internalType: 'string', - name: 'passportNumber', - type: 'string', - }, - { - internalType: 'string', - name: 'nationality', - type: 'string', - }, - { - internalType: 'string', - name: 'dateOfBirth', - type: 'string', - }, - { - internalType: 'string', - name: 'gender', - type: 'string', - }, - { - internalType: 'string', - name: 'expiryDate', - type: 'string', - }, - { - internalType: 'uint256', - name: 'olderThan', - type: 'uint256', - }, - { - internalType: 'uint256', - name: 'passportNoOfac', - type: 'uint256', - }, - { - internalType: 'uint256', - name: 'nameAndDobOfac', - type: 'uint256', - }, - { - internalType: 'uint256', - name: 'nameAndYobOfac', - type: 'uint256', - }, - ], - internalType: 'struct IIdentityVerificationHubV1.ReadableRevealedData', - name: '', - type: 'tuple', - }, - { - internalType: 'bool', - name: '', - type: 'bool', - }, - { - internalType: 'string', - name: '', - type: 'string', - }, - ], - stateMutability: 'view', - type: 'function', - }, -]; diff --git a/sdk/core/src/constants/contractAddresses.ts b/sdk/core/src/constants/contractAddresses.ts deleted file mode 100644 index 60c25de20..000000000 --- a/sdk/core/src/constants/contractAddresses.ts +++ /dev/null @@ -1,4 +0,0 @@ -export const REGISTRY_ADDRESS = '0x37F5CB8cB1f6B00aa768D8aA99F1A9289802A968'; -export const REGISTRY_ADDRESS_STAGING = '0xbC42aA9EF1926D980A2c50b5594586AA7bfF2341'; -export const VERIFYALL_ADDRESS = '0xe6D61680A6ED381bb5A0dB5cF4E9Cc933cF43915'; -export const VERIFYALL_ADDRESS_STAGING = '0x03237E7b4c2b1AdEBdBC33d91478Eaef05D0fF85'; diff --git a/sdk/core/src/errors.ts b/sdk/core/src/errors.ts new file mode 100644 index 000000000..715065ebd --- /dev/null +++ b/sdk/core/src/errors.ts @@ -0,0 +1,44 @@ +export enum ConfigMismatch { + InvalidId = 'InvalidId', + InvalidUserContextHash = 'InvalidUserContextHash', + InvalidScope = 'InvalidScope', + InvalidRoot = 'InvalidRoot', + InvalidAttestationId = 'InvalidAttestationId', + InvalidForbiddenCountriesList = 'InvalidForbiddenCountriesList', + InvalidMinimumAge = 'InvalidMinimumAge', + InvalidTimestamp = 'InvalidTimestamp', + InvalidOfac = 'InvalidOfac' +} + +export class ConfigMismatchError extends Error { + public readonly issues: Array<{ type: ConfigMismatch; message: string }>; + + constructor(issues: Array<{ type: ConfigMismatch; message: string }>) { + const message = issues.map(issue => `[${issue.type}]: ${issue.message}`).join('\n'); + super(message); + this.name = 'ConfigMismatchError'; + this.issues = issues; + + Object.setPrototypeOf(this, ConfigMismatchError.prototype); + } + + static single(type: ConfigMismatch, message: string): ConfigMismatchError { + return new ConfigMismatchError([{ type, message }]); + } +} + +export enum InvalidProof { + InvalidProof = 'InvalidProof', +} + +export class InvalidProofError extends Error { + public readonly type: InvalidProof; + + constructor(type: InvalidProof, message: string) { + super(`[${type}]: ${message}`); + this.name = 'InvalidProofError'; + this.type = type; + + Object.setPrototypeOf(this, InvalidProofError.prototype); + } +} diff --git a/sdk/core/src/store/DefaultConfigStore.ts b/sdk/core/src/store/DefaultConfigStore.ts new file mode 100644 index 000000000..b8aec7bd3 --- /dev/null +++ b/sdk/core/src/store/DefaultConfigStore.ts @@ -0,0 +1,19 @@ +import { VerificationConfig } from "src/types/types.js"; +import { IConfigStorage } from "./interface.js"; + +export class DefaultConfigStore implements IConfigStorage { + constructor(private config: VerificationConfig) {} + + async getConfig(_id: string): Promise { + return this.config; + } + + async setConfig(_id: string, config: VerificationConfig): Promise { + this.config = config; + return true; + } + + async getActionId(_userIdentifier: string, _data: string): Promise { + return ""; + } +} diff --git a/sdk/core/src/store/interface.ts b/sdk/core/src/store/interface.ts new file mode 100644 index 000000000..545133614 --- /dev/null +++ b/sdk/core/src/store/interface.ts @@ -0,0 +1,23 @@ +import { VerificationConfig } from "../types/types.js"; + +export interface IConfigStorage { + /** + * Get the verification config for a given id + * @param id - An identifiier associated with the verification config + * @returns The verification config + */ + getConfig(id: string): Promise; + /** + * Set the verification config for a given id + * @param id - An identifiier associated with the verification config + * @param config - The verification config + * @returns True if the config was set successfully, false otherwise + */ + setConfig(id: string, config: VerificationConfig): Promise; + /** + * Get the action id for given user defined data passed in the frontend + * @param data - The user defined data passed in the frontend + * @returns The action id + */ + getActionId(userIdentifier: string, data: string): Promise; +} diff --git a/sdk/core/src/typechain-types/IdentityVerificationHubImpl.ts b/sdk/core/src/typechain-types/IdentityVerificationHubImpl.ts index ddedddc7a..581968f2f 100644 --- a/sdk/core/src/typechain-types/IdentityVerificationHubImpl.ts +++ b/sdk/core/src/typechain-types/IdentityVerificationHubImpl.ts @@ -23,6 +23,35 @@ import type { TypedContractMethod, } from "./common.js"; +export declare namespace SelfStructs { + export type VerificationConfigV2Struct = { + olderThanEnabled: boolean; + olderThan: BigNumberish; + forbiddenCountriesEnabled: boolean; + forbiddenCountriesListPacked: [ + BigNumberish, + BigNumberish, + BigNumberish, + BigNumberish + ]; + ofacEnabled: [boolean, boolean, boolean]; + }; + + export type VerificationConfigV2StructOutput = [ + olderThanEnabled: boolean, + olderThan: bigint, + forbiddenCountriesEnabled: boolean, + forbiddenCountriesListPacked: [bigint, bigint, bigint, bigint], + ofacEnabled: [boolean, boolean, boolean] + ] & { + olderThanEnabled: boolean; + olderThan: bigint; + forbiddenCountriesEnabled: boolean; + forbiddenCountriesListPacked: [bigint, bigint, bigint, bigint]; + ofacEnabled: [boolean, boolean, boolean]; + }; +} + export declare namespace IRegisterCircuitVerifier { export type RegisterCircuitProofStruct = { a: [BigNumberish, BigNumberish]; @@ -72,30 +101,35 @@ export interface IdentityVerificationHubImplInterface extends Interface { | "acceptOwnership" | "batchUpdateDscCircuitVerifiers" | "batchUpdateRegisterCircuitVerifiers" + | "discloseVerifier" + | "dscCircuitVerifiers" + | "generateConfigId" + | "getIdentityCommitmentMerkleRoot" | "initialize" | "owner" | "pendingOwner" | "proxiableUUID" + | "registerCircuitVerifiers" | "registerCommitment" | "registerDscKeyCommitment" | "registry" | "renounceOwnership" - | "sigTypeToDscCircuitVerifiers" - | "sigTypeToRegisterCircuitVerifiers" + | "rootTimestamp" + | "setVerificationConfigV2" | "transferOwnership" | "updateDscVerifier" | "updateRegisterCircuitVerifier" | "updateRegistry" | "updateVcAndDiscloseCircuit" | "upgradeToAndCall" - | "vcAndDiscloseCircuitVerifier" - | "verifyVcAndDisclose" + | "verificationConfigV2Exists" + | "verify" ): FunctionFragment; getEvent( nameOrSignatureOrTopic: | "DscCircuitVerifierUpdated" - | "HubInitialized" + | "HubInitializedV2" | "Initialized" | "OwnershipTransferStarted" | "OwnershipTransferred" @@ -103,6 +137,7 @@ export interface IdentityVerificationHubImplInterface extends Interface { | "RegistryUpdated" | "Upgraded" | "VcAndDiscloseCircuitUpdated" + | "VerificationConfigV2Set" ): EventFragment; encodeFunctionData( @@ -115,23 +150,31 @@ export interface IdentityVerificationHubImplInterface extends Interface { ): string; encodeFunctionData( functionFragment: "batchUpdateDscCircuitVerifiers", - values: [BigNumberish[], AddressLike[]] + values: [BytesLike[], BigNumberish[], AddressLike[]] ): string; encodeFunctionData( functionFragment: "batchUpdateRegisterCircuitVerifiers", - values: [BigNumberish[], AddressLike[]] + values: [BytesLike[], BigNumberish[], AddressLike[]] + ): string; + encodeFunctionData( + functionFragment: "discloseVerifier", + values: [BytesLike] + ): string; + encodeFunctionData( + functionFragment: "dscCircuitVerifiers", + values: [BytesLike, BigNumberish] + ): string; + encodeFunctionData( + functionFragment: "generateConfigId", + values: [SelfStructs.VerificationConfigV2Struct] + ): string; + encodeFunctionData( + functionFragment: "getIdentityCommitmentMerkleRoot", + values: [BytesLike] ): string; encodeFunctionData( functionFragment: "initialize", - values: [ - BytesLike[], - AddressLike[], - AddressLike[], - BigNumberish[], - AddressLike[], - BigNumberish[], - AddressLike[] - ] + values?: undefined ): string; encodeFunctionData(functionFragment: "owner", values?: undefined): string; encodeFunctionData( @@ -142,6 +185,10 @@ export interface IdentityVerificationHubImplInterface extends Interface { functionFragment: "proxiableUUID", values?: undefined ): string; + encodeFunctionData( + functionFragment: "registerCircuitVerifiers", + values: [BytesLike, BigNumberish] + ): string; encodeFunctionData( functionFragment: "registerCommitment", values: [ @@ -160,12 +207,12 @@ export interface IdentityVerificationHubImplInterface extends Interface { values?: undefined ): string; encodeFunctionData( - functionFragment: "sigTypeToDscCircuitVerifiers", - values: [BigNumberish] + functionFragment: "rootTimestamp", + values: [BytesLike, BigNumberish] ): string; encodeFunctionData( - functionFragment: "sigTypeToRegisterCircuitVerifiers", - values: [BigNumberish] + functionFragment: "setVerificationConfigV2", + values: [SelfStructs.VerificationConfigV2Struct] ): string; encodeFunctionData( functionFragment: "transferOwnership", @@ -173,11 +220,11 @@ export interface IdentityVerificationHubImplInterface extends Interface { ): string; encodeFunctionData( functionFragment: "updateDscVerifier", - values: [BigNumberish, AddressLike] + values: [BytesLike, BigNumberish, AddressLike] ): string; encodeFunctionData( functionFragment: "updateRegisterCircuitVerifier", - values: [BigNumberish, AddressLike] + values: [BytesLike, BigNumberish, AddressLike] ): string; encodeFunctionData( functionFragment: "updateRegistry", @@ -192,12 +239,12 @@ export interface IdentityVerificationHubImplInterface extends Interface { values: [AddressLike, BytesLike] ): string; encodeFunctionData( - functionFragment: "vcAndDiscloseCircuitVerifier", + functionFragment: "verificationConfigV2Exists", values: [BytesLike] ): string; encodeFunctionData( - functionFragment: "verifyVcAndDisclose", - values: [BytesLike] + functionFragment: "verify", + values: [BytesLike, BytesLike] ): string; decodeFunctionResult( @@ -216,6 +263,22 @@ export interface IdentityVerificationHubImplInterface extends Interface { functionFragment: "batchUpdateRegisterCircuitVerifiers", data: BytesLike ): Result; + decodeFunctionResult( + functionFragment: "discloseVerifier", + data: BytesLike + ): Result; + decodeFunctionResult( + functionFragment: "dscCircuitVerifiers", + data: BytesLike + ): Result; + decodeFunctionResult( + functionFragment: "generateConfigId", + data: BytesLike + ): Result; + decodeFunctionResult( + functionFragment: "getIdentityCommitmentMerkleRoot", + data: BytesLike + ): Result; decodeFunctionResult(functionFragment: "initialize", data: BytesLike): Result; decodeFunctionResult(functionFragment: "owner", data: BytesLike): Result; decodeFunctionResult( @@ -226,6 +289,10 @@ export interface IdentityVerificationHubImplInterface extends Interface { functionFragment: "proxiableUUID", data: BytesLike ): Result; + decodeFunctionResult( + functionFragment: "registerCircuitVerifiers", + data: BytesLike + ): Result; decodeFunctionResult( functionFragment: "registerCommitment", data: BytesLike @@ -240,11 +307,11 @@ export interface IdentityVerificationHubImplInterface extends Interface { data: BytesLike ): Result; decodeFunctionResult( - functionFragment: "sigTypeToDscCircuitVerifiers", + functionFragment: "rootTimestamp", data: BytesLike ): Result; decodeFunctionResult( - functionFragment: "sigTypeToRegisterCircuitVerifiers", + functionFragment: "setVerificationConfigV2", data: BytesLike ): Result; decodeFunctionResult( @@ -272,13 +339,10 @@ export interface IdentityVerificationHubImplInterface extends Interface { data: BytesLike ): Result; decodeFunctionResult( - functionFragment: "vcAndDiscloseCircuitVerifier", - data: BytesLike - ): Result; - decodeFunctionResult( - functionFragment: "verifyVcAndDisclose", + functionFragment: "verificationConfigV2Exists", data: BytesLike ): Result; + decodeFunctionResult(functionFragment: "verify", data: BytesLike): Result; } export namespace DscCircuitVerifierUpdatedEvent { @@ -294,34 +358,10 @@ export namespace DscCircuitVerifierUpdatedEvent { export type LogDescription = TypedLogDescription; } -export namespace HubInitializedEvent { - export type InputTuple = [ - attestationIds: BytesLike[], - registryAddresses: AddressLike[], - vcAndDiscloseCircuitVerifiers: AddressLike[], - registerCircuitVerifierIds: BigNumberish[], - registerCircuitVerifiers: AddressLike[], - dscCircuitVerifierIds: BigNumberish[], - dscCircuitVerifiers: AddressLike[] - ]; - export type OutputTuple = [ - attestationIds: string[], - registryAddresses: string[], - vcAndDiscloseCircuitVerifiers: string[], - registerCircuitVerifierIds: bigint[], - registerCircuitVerifiers: string[], - dscCircuitVerifierIds: bigint[], - dscCircuitVerifiers: string[] - ]; - export interface OutputObject { - attestationIds: string[]; - registryAddresses: string[]; - vcAndDiscloseCircuitVerifiers: string[]; - registerCircuitVerifierIds: bigint[]; - registerCircuitVerifiers: string[]; - dscCircuitVerifierIds: bigint[]; - dscCircuitVerifiers: string[]; - } +export namespace HubInitializedV2Event { + export type InputTuple = []; + export type OutputTuple = []; + export interface OutputObject {} export type Event = TypedContractEvent; export type Filter = TypedDeferredTopicFilter; export type Log = TypedEventLog; @@ -423,6 +463,25 @@ export namespace VcAndDiscloseCircuitUpdatedEvent { export type LogDescription = TypedLogDescription; } +export namespace VerificationConfigV2SetEvent { + export type InputTuple = [ + configId: BytesLike, + config: SelfStructs.VerificationConfigV2Struct + ]; + export type OutputTuple = [ + configId: string, + config: SelfStructs.VerificationConfigV2StructOutput + ]; + export interface OutputObject { + configId: string; + config: SelfStructs.VerificationConfigV2StructOutput; + } + export type Event = TypedContractEvent; + export type Filter = TypedDeferredTopicFilter; + export type Log = TypedEventLog; + export type LogDescription = TypedLogDescription; +} + export interface IdentityVerificationHubImpl extends BaseContract { connect(runner?: ContractRunner | null): IdentityVerificationHubImpl; waitForDeployment(): Promise; @@ -471,37 +530,63 @@ export interface IdentityVerificationHubImpl extends BaseContract { acceptOwnership: TypedContractMethod<[], [void], "nonpayable">; batchUpdateDscCircuitVerifiers: TypedContractMethod< - [typeIds: BigNumberish[], verifierAddresses: AddressLike[]], + [ + attestationIds: BytesLike[], + typeIds: BigNumberish[], + verifierAddresses: AddressLike[] + ], [void], "nonpayable" >; batchUpdateRegisterCircuitVerifiers: TypedContractMethod< - [typeIds: BigNumberish[], verifierAddresses: AddressLike[]], - [void], - "nonpayable" - >; - - initialize: TypedContractMethod< [ attestationIds: BytesLike[], - registryAddresses: AddressLike[], - vcAndDiscloseCircuitVerifierAddresses: AddressLike[], - registerCircuitVerifierIds: BigNumberish[], - registerCircuitVerifierAddresses: AddressLike[], - dscCircuitVerifierIds: BigNumberish[], - dscCircuitVerifierAddresses: AddressLike[] + typeIds: BigNumberish[], + verifierAddresses: AddressLike[] ], [void], "nonpayable" >; + discloseVerifier: TypedContractMethod< + [attestationId: BytesLike], + [string], + "view" + >; + + dscCircuitVerifiers: TypedContractMethod< + [attestationId: BytesLike, typeId: BigNumberish], + [string], + "view" + >; + + generateConfigId: TypedContractMethod< + [config: SelfStructs.VerificationConfigV2Struct], + [string], + "view" + >; + + getIdentityCommitmentMerkleRoot: TypedContractMethod< + [attestationId: BytesLike], + [bigint], + "view" + >; + + initialize: TypedContractMethod<[], [void], "nonpayable">; + owner: TypedContractMethod<[], [string], "view">; pendingOwner: TypedContractMethod<[], [string], "view">; proxiableUUID: TypedContractMethod<[], [string], "view">; + registerCircuitVerifiers: TypedContractMethod< + [attestationId: BytesLike, typeId: BigNumberish], + [string], + "view" + >; + registerCommitment: TypedContractMethod< [ attestationId: BytesLike, @@ -526,16 +611,16 @@ export interface IdentityVerificationHubImpl extends BaseContract { renounceOwnership: TypedContractMethod<[], [void], "nonpayable">; - sigTypeToDscCircuitVerifiers: TypedContractMethod< - [typeId: BigNumberish], - [string], + rootTimestamp: TypedContractMethod< + [attestationId: BytesLike, root: BigNumberish], + [bigint], "view" >; - sigTypeToRegisterCircuitVerifiers: TypedContractMethod< - [typeId: BigNumberish], + setVerificationConfigV2: TypedContractMethod< + [config: SelfStructs.VerificationConfigV2Struct], [string], - "view" + "nonpayable" >; transferOwnership: TypedContractMethod< @@ -545,13 +630,21 @@ export interface IdentityVerificationHubImpl extends BaseContract { >; updateDscVerifier: TypedContractMethod< - [typeId: BigNumberish, verifierAddress: AddressLike], + [ + attestationId: BytesLike, + typeId: BigNumberish, + verifierAddress: AddressLike + ], [void], "nonpayable" >; updateRegisterCircuitVerifier: TypedContractMethod< - [typeId: BigNumberish, verifierAddress: AddressLike], + [ + attestationId: BytesLike, + typeId: BigNumberish, + verifierAddress: AddressLike + ], [void], "nonpayable" >; @@ -577,16 +670,16 @@ export interface IdentityVerificationHubImpl extends BaseContract { "payable" >; - vcAndDiscloseCircuitVerifier: TypedContractMethod< - [attestationId: BytesLike], - [string], + verificationConfigV2Exists: TypedContractMethod< + [configId: BytesLike], + [boolean], "view" >; - verifyVcAndDisclose: TypedContractMethod< - [proofData: BytesLike], - [string], - "view" + verify: TypedContractMethod< + [baseVerificationInput: BytesLike, userContextData: BytesLike], + [void], + "nonpayable" >; getFunction( @@ -602,32 +695,48 @@ export interface IdentityVerificationHubImpl extends BaseContract { getFunction( nameOrSignature: "batchUpdateDscCircuitVerifiers" ): TypedContractMethod< - [typeIds: BigNumberish[], verifierAddresses: AddressLike[]], + [ + attestationIds: BytesLike[], + typeIds: BigNumberish[], + verifierAddresses: AddressLike[] + ], [void], "nonpayable" >; getFunction( nameOrSignature: "batchUpdateRegisterCircuitVerifiers" - ): TypedContractMethod< - [typeIds: BigNumberish[], verifierAddresses: AddressLike[]], - [void], - "nonpayable" - >; - getFunction( - nameOrSignature: "initialize" ): TypedContractMethod< [ attestationIds: BytesLike[], - registryAddresses: AddressLike[], - vcAndDiscloseCircuitVerifierAddresses: AddressLike[], - registerCircuitVerifierIds: BigNumberish[], - registerCircuitVerifierAddresses: AddressLike[], - dscCircuitVerifierIds: BigNumberish[], - dscCircuitVerifierAddresses: AddressLike[] + typeIds: BigNumberish[], + verifierAddresses: AddressLike[] ], [void], "nonpayable" >; + getFunction( + nameOrSignature: "discloseVerifier" + ): TypedContractMethod<[attestationId: BytesLike], [string], "view">; + getFunction( + nameOrSignature: "dscCircuitVerifiers" + ): TypedContractMethod< + [attestationId: BytesLike, typeId: BigNumberish], + [string], + "view" + >; + getFunction( + nameOrSignature: "generateConfigId" + ): TypedContractMethod< + [config: SelfStructs.VerificationConfigV2Struct], + [string], + "view" + >; + getFunction( + nameOrSignature: "getIdentityCommitmentMerkleRoot" + ): TypedContractMethod<[attestationId: BytesLike], [bigint], "view">; + getFunction( + nameOrSignature: "initialize" + ): TypedContractMethod<[], [void], "nonpayable">; getFunction( nameOrSignature: "owner" ): TypedContractMethod<[], [string], "view">; @@ -637,6 +746,13 @@ export interface IdentityVerificationHubImpl extends BaseContract { getFunction( nameOrSignature: "proxiableUUID" ): TypedContractMethod<[], [string], "view">; + getFunction( + nameOrSignature: "registerCircuitVerifiers" + ): TypedContractMethod< + [attestationId: BytesLike, typeId: BigNumberish], + [string], + "view" + >; getFunction( nameOrSignature: "registerCommitment" ): TypedContractMethod< @@ -666,25 +782,41 @@ export interface IdentityVerificationHubImpl extends BaseContract { nameOrSignature: "renounceOwnership" ): TypedContractMethod<[], [void], "nonpayable">; getFunction( - nameOrSignature: "sigTypeToDscCircuitVerifiers" - ): TypedContractMethod<[typeId: BigNumberish], [string], "view">; + nameOrSignature: "rootTimestamp" + ): TypedContractMethod< + [attestationId: BytesLike, root: BigNumberish], + [bigint], + "view" + >; getFunction( - nameOrSignature: "sigTypeToRegisterCircuitVerifiers" - ): TypedContractMethod<[typeId: BigNumberish], [string], "view">; + nameOrSignature: "setVerificationConfigV2" + ): TypedContractMethod< + [config: SelfStructs.VerificationConfigV2Struct], + [string], + "nonpayable" + >; getFunction( nameOrSignature: "transferOwnership" ): TypedContractMethod<[newOwner: AddressLike], [void], "nonpayable">; getFunction( nameOrSignature: "updateDscVerifier" ): TypedContractMethod< - [typeId: BigNumberish, verifierAddress: AddressLike], + [ + attestationId: BytesLike, + typeId: BigNumberish, + verifierAddress: AddressLike + ], [void], "nonpayable" >; getFunction( nameOrSignature: "updateRegisterCircuitVerifier" ): TypedContractMethod< - [typeId: BigNumberish, verifierAddress: AddressLike], + [ + attestationId: BytesLike, + typeId: BigNumberish, + verifierAddress: AddressLike + ], [void], "nonpayable" >; @@ -713,11 +845,15 @@ export interface IdentityVerificationHubImpl extends BaseContract { "payable" >; getFunction( - nameOrSignature: "vcAndDiscloseCircuitVerifier" - ): TypedContractMethod<[attestationId: BytesLike], [string], "view">; + nameOrSignature: "verificationConfigV2Exists" + ): TypedContractMethod<[configId: BytesLike], [boolean], "view">; getFunction( - nameOrSignature: "verifyVcAndDisclose" - ): TypedContractMethod<[proofData: BytesLike], [string], "view">; + nameOrSignature: "verify" + ): TypedContractMethod< + [baseVerificationInput: BytesLike, userContextData: BytesLike], + [void], + "nonpayable" + >; getEvent( key: "DscCircuitVerifierUpdated" @@ -727,11 +863,11 @@ export interface IdentityVerificationHubImpl extends BaseContract { DscCircuitVerifierUpdatedEvent.OutputObject >; getEvent( - key: "HubInitialized" + key: "HubInitializedV2" ): TypedContractEvent< - HubInitializedEvent.InputTuple, - HubInitializedEvent.OutputTuple, - HubInitializedEvent.OutputObject + HubInitializedV2Event.InputTuple, + HubInitializedV2Event.OutputTuple, + HubInitializedV2Event.OutputObject >; getEvent( key: "Initialized" @@ -782,6 +918,13 @@ export interface IdentityVerificationHubImpl extends BaseContract { VcAndDiscloseCircuitUpdatedEvent.OutputTuple, VcAndDiscloseCircuitUpdatedEvent.OutputObject >; + getEvent( + key: "VerificationConfigV2Set" + ): TypedContractEvent< + VerificationConfigV2SetEvent.InputTuple, + VerificationConfigV2SetEvent.OutputTuple, + VerificationConfigV2SetEvent.OutputObject + >; filters: { "DscCircuitVerifierUpdated(uint256,address)": TypedContractEvent< @@ -795,15 +938,15 @@ export interface IdentityVerificationHubImpl extends BaseContract { DscCircuitVerifierUpdatedEvent.OutputObject >; - "HubInitialized(bytes32[],address[],address[],uint256[],address[],uint256[],address[])": TypedContractEvent< - HubInitializedEvent.InputTuple, - HubInitializedEvent.OutputTuple, - HubInitializedEvent.OutputObject + "HubInitializedV2()": TypedContractEvent< + HubInitializedV2Event.InputTuple, + HubInitializedV2Event.OutputTuple, + HubInitializedV2Event.OutputObject >; - HubInitialized: TypedContractEvent< - HubInitializedEvent.InputTuple, - HubInitializedEvent.OutputTuple, - HubInitializedEvent.OutputObject + HubInitializedV2: TypedContractEvent< + HubInitializedV2Event.InputTuple, + HubInitializedV2Event.OutputTuple, + HubInitializedV2Event.OutputObject >; "Initialized(uint64)": TypedContractEvent< @@ -882,5 +1025,16 @@ export interface IdentityVerificationHubImpl extends BaseContract { VcAndDiscloseCircuitUpdatedEvent.OutputTuple, VcAndDiscloseCircuitUpdatedEvent.OutputObject >; + + "VerificationConfigV2Set(bytes32,tuple)": TypedContractEvent< + VerificationConfigV2SetEvent.InputTuple, + VerificationConfigV2SetEvent.OutputTuple, + VerificationConfigV2SetEvent.OutputObject + >; + VerificationConfigV2Set: TypedContractEvent< + VerificationConfigV2SetEvent.InputTuple, + VerificationConfigV2SetEvent.OutputTuple, + VerificationConfigV2SetEvent.OutputObject + >; }; } diff --git a/sdk/core/src/typechain-types/Registry.ts b/sdk/core/src/typechain-types/Registry.ts new file mode 100644 index 000000000..57a2cc009 --- /dev/null +++ b/sdk/core/src/typechain-types/Registry.ts @@ -0,0 +1,95 @@ +/* Autogenerated file. Do not edit manually. */ +/* tslint:disable */ +/* eslint-disable */ +import type { + BaseContract, + BigNumberish, + BytesLike, + FunctionFragment, + Result, + Interface, + ContractRunner, + ContractMethod, + Listener, +} from "ethers"; +import type { + TypedContractEvent, + TypedDeferredTopicFilter, + TypedEventLog, + TypedListener, + TypedContractMethod, +} from "./common.js"; + +export interface RegistryInterface extends Interface { + getFunction(nameOrSignature: "checkIdentityCommitmentRoot"): FunctionFragment; + + encodeFunctionData( + functionFragment: "checkIdentityCommitmentRoot", + values: [BigNumberish] + ): string; + + decodeFunctionResult( + functionFragment: "checkIdentityCommitmentRoot", + data: BytesLike + ): Result; +} + +export interface Registry extends BaseContract { + connect(runner?: ContractRunner | null): Registry; + waitForDeployment(): Promise; + + interface: RegistryInterface; + + queryFilter( + event: TCEvent, + fromBlockOrBlockhash?: string | number | undefined, + toBlock?: string | number | undefined + ): Promise>>; + queryFilter( + filter: TypedDeferredTopicFilter, + fromBlockOrBlockhash?: string | number | undefined, + toBlock?: string | number | undefined + ): Promise>>; + + on( + event: TCEvent, + listener: TypedListener + ): Promise; + on( + filter: TypedDeferredTopicFilter, + listener: TypedListener + ): Promise; + + once( + event: TCEvent, + listener: TypedListener + ): Promise; + once( + filter: TypedDeferredTopicFilter, + listener: TypedListener + ): Promise; + + listeners( + event: TCEvent + ): Promise>>; + listeners(eventName?: string): Promise>; + removeAllListeners( + event?: TCEvent + ): Promise; + + checkIdentityCommitmentRoot: TypedContractMethod< + [root: BigNumberish], + [boolean], + "view" + >; + + getFunction( + key: string | FunctionFragment + ): T; + + getFunction( + nameOrSignature: "checkIdentityCommitmentRoot" + ): TypedContractMethod<[root: BigNumberish], [boolean], "view">; + + filters: {}; +} diff --git a/sdk/core/src/typechain-types/Verifier.ts b/sdk/core/src/typechain-types/Verifier.ts new file mode 100644 index 000000000..4b7200bea --- /dev/null +++ b/sdk/core/src/typechain-types/Verifier.ts @@ -0,0 +1,114 @@ +/* Autogenerated file. Do not edit manually. */ +/* tslint:disable */ +/* eslint-disable */ +import type { + BaseContract, + BigNumberish, + BytesLike, + FunctionFragment, + Result, + Interface, + ContractRunner, + ContractMethod, + Listener, +} from "ethers"; +import type { + TypedContractEvent, + TypedDeferredTopicFilter, + TypedEventLog, + TypedListener, + TypedContractMethod, +} from "./common.js"; + +export interface VerifierInterface extends Interface { + getFunction(nameOrSignature: "verifyProof"): FunctionFragment; + + encodeFunctionData( + functionFragment: "verifyProof", + values: [ + [BigNumberish, BigNumberish], + [[BigNumberish, BigNumberish], [BigNumberish, BigNumberish]], + [BigNumberish, BigNumberish], + BigNumberish[] + ] + ): string; + + decodeFunctionResult( + functionFragment: "verifyProof", + data: BytesLike + ): Result; +} + +export interface Verifier extends BaseContract { + connect(runner?: ContractRunner | null): Verifier; + waitForDeployment(): Promise; + + interface: VerifierInterface; + + queryFilter( + event: TCEvent, + fromBlockOrBlockhash?: string | number | undefined, + toBlock?: string | number | undefined + ): Promise>>; + queryFilter( + filter: TypedDeferredTopicFilter, + fromBlockOrBlockhash?: string | number | undefined, + toBlock?: string | number | undefined + ): Promise>>; + + on( + event: TCEvent, + listener: TypedListener + ): Promise; + on( + filter: TypedDeferredTopicFilter, + listener: TypedListener + ): Promise; + + once( + event: TCEvent, + listener: TypedListener + ): Promise; + once( + filter: TypedDeferredTopicFilter, + listener: TypedListener + ): Promise; + + listeners( + event: TCEvent + ): Promise>>; + listeners(eventName?: string): Promise>; + removeAllListeners( + event?: TCEvent + ): Promise; + + verifyProof: TypedContractMethod< + [ + a: [BigNumberish, BigNumberish], + b: [[BigNumberish, BigNumberish], [BigNumberish, BigNumberish]], + c: [BigNumberish, BigNumberish], + pubSignals: BigNumberish[] + ], + [boolean], + "view" + >; + + getFunction( + key: string | FunctionFragment + ): T; + + getFunction( + nameOrSignature: "verifyProof" + ): TypedContractMethod< + [ + a: [BigNumberish, BigNumberish], + b: [[BigNumberish, BigNumberish], [BigNumberish, BigNumberish]], + c: [BigNumberish, BigNumberish], + pubSignals: BigNumberish[] + ], + [boolean], + "view" + >; + + filters: {}; +} diff --git a/sdk/core/src/typechain-types/factories/IdentityVerificationHubImpl__factory.ts b/sdk/core/src/typechain-types/factories/IdentityVerificationHubImpl__factory.ts index 619f5fd65..cb238dd6d 100644 --- a/sdk/core/src/typechain-types/factories/IdentityVerificationHubImpl__factory.ts +++ b/sdk/core/src/typechain-types/factories/IdentityVerificationHubImpl__factory.ts @@ -27,7 +27,12 @@ const _abi = [ }, { inputs: [], - name: "CURRENT_DATE_NOT_IN_VALID_RANGE", + name: "CrossChainIsNotSupportedYet", + type: "error", + }, + { + inputs: [], + name: "CurrentDateNotInValidRange", type: "error", }, { @@ -53,87 +58,77 @@ const _abi = [ }, { inputs: [], - name: "INVALID_ATTESTATION_ID", + name: "InputTooShort", type: "error", }, { inputs: [], - name: "INVALID_COMMITMENT_ROOT", + name: "InvalidAttestationId", type: "error", }, { inputs: [], - name: "INVALID_CSCA_ROOT", + name: "InvalidCscaRoot", type: "error", }, { inputs: [], - name: "INVALID_DSC_PROOF", - type: "error", - }, - { - inputs: [], - name: "INVALID_FORBIDDEN_COUNTRIES", - type: "error", - }, - { - inputs: [], - name: "INVALID_OFAC", + name: "InvalidDateDigit", type: "error", }, { inputs: [], - name: "INVALID_OFAC_ROOT", + name: "InvalidDateLength", type: "error", }, { inputs: [], - name: "INVALID_OLDER_THAN", + name: "InvalidDayRange", type: "error", }, { inputs: [], - name: "INVALID_REGISTER_PROOF", + name: "InvalidDscCommitmentRoot", type: "error", }, { inputs: [], - name: "INVALID_REVEALED_DATA_TYPE", + name: "InvalidDscProof", type: "error", }, { inputs: [], - name: "INVALID_VC_AND_DISCLOSE_PROOF", + name: "InvalidFieldElement", type: "error", }, { inputs: [], - name: "InvalidDateDigit", + name: "InvalidIdentityCommitmentRoot", type: "error", }, { inputs: [], - name: "InvalidDateLength", + name: "InvalidInitialization", type: "error", }, { inputs: [], - name: "InvalidDayRange", + name: "InvalidMonthRange", type: "error", }, { inputs: [], - name: "InvalidFieldElement", + name: "InvalidRegisterProof", type: "error", }, { inputs: [], - name: "InvalidInitialization", + name: "InvalidUserIdentifierInProof", type: "error", }, { inputs: [], - name: "InvalidMonthRange", + name: "InvalidVcAndDiscloseProof", type: "error", }, { @@ -143,12 +138,12 @@ const _abi = [ }, { inputs: [], - name: "LENGTH_MISMATCH", + name: "LengthMismatch", type: "error", }, { inputs: [], - name: "NO_VERIFIER_SET", + name: "NoVerifierSet", type: "error", }, { @@ -178,6 +173,11 @@ const _abi = [ name: "OwnableUnauthorizedAccount", type: "error", }, + { + inputs: [], + name: "ScopeMismatch", + type: "error", + }, { inputs: [], name: "UUPSUnauthorizedCallContext", @@ -194,6 +194,11 @@ const _abi = [ name: "UUPSUnsupportedProxiableUUID", type: "error", }, + { + inputs: [], + name: "UserContextDataTooShort", + type: "error", + }, { anonymous: false, inputs: [ @@ -215,51 +220,8 @@ const _abi = [ }, { anonymous: false, - inputs: [ - { - indexed: false, - internalType: "bytes32[]", - name: "attestationIds", - type: "bytes32[]", - }, - { - indexed: false, - internalType: "address[]", - name: "registryAddresses", - type: "address[]", - }, - { - indexed: false, - internalType: "address[]", - name: "vcAndDiscloseCircuitVerifiers", - type: "address[]", - }, - { - indexed: false, - internalType: "uint256[]", - name: "registerCircuitVerifierIds", - type: "uint256[]", - }, - { - indexed: false, - internalType: "address[]", - name: "registerCircuitVerifiers", - type: "address[]", - }, - { - indexed: false, - internalType: "uint256[]", - name: "dscCircuitVerifierIds", - type: "uint256[]", - }, - { - indexed: false, - internalType: "address[]", - name: "dscCircuitVerifiers", - type: "address[]", - }, - ], - name: "HubInitialized", + inputs: [], + name: "HubInitializedV2", type: "event", }, { @@ -383,6 +345,52 @@ const _abi = [ name: "VcAndDiscloseCircuitUpdated", type: "event", }, + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: "bytes32", + name: "configId", + type: "bytes32", + }, + { + components: [ + { + internalType: "bool", + name: "olderThanEnabled", + type: "bool", + }, + { + internalType: "uint256", + name: "olderThan", + type: "uint256", + }, + { + internalType: "bool", + name: "forbiddenCountriesEnabled", + type: "bool", + }, + { + internalType: "uint256[4]", + name: "forbiddenCountriesListPacked", + type: "uint256[4]", + }, + { + internalType: "bool[3]", + name: "ofacEnabled", + type: "bool[3]", + }, + ], + indexed: false, + internalType: "struct SelfStructs.VerificationConfigV2", + name: "config", + type: "tuple", + }, + ], + name: "VerificationConfigV2Set", + type: "event", + }, { inputs: [], name: "UPGRADE_INTERFACE_VERSION", @@ -405,6 +413,11 @@ const _abi = [ }, { inputs: [ + { + internalType: "bytes32[]", + name: "attestationIds", + type: "bytes32[]", + }, { internalType: "uint256[]", name: "typeIds", @@ -423,6 +436,11 @@ const _abi = [ }, { inputs: [ + { + internalType: "bytes32[]", + name: "attestationIds", + type: "bytes32[]", + }, { internalType: "uint256[]", name: "typeIds", @@ -442,41 +460,113 @@ const _abi = [ { inputs: [ { - internalType: "bytes32[]", - name: "attestationIds", - type: "bytes32[]", + internalType: "bytes32", + name: "attestationId", + type: "bytes32", }, + ], + name: "discloseVerifier", + outputs: [ { - internalType: "address[]", - name: "registryAddresses", - type: "address[]", + internalType: "address", + name: "", + type: "address", }, + ], + stateMutability: "view", + type: "function", + }, + { + inputs: [ { - internalType: "address[]", - name: "vcAndDiscloseCircuitVerifierAddresses", - type: "address[]", + internalType: "bytes32", + name: "attestationId", + type: "bytes32", }, { - internalType: "uint256[]", - name: "registerCircuitVerifierIds", - type: "uint256[]", + internalType: "uint256", + name: "typeId", + type: "uint256", }, + ], + name: "dscCircuitVerifiers", + outputs: [ { - internalType: "address[]", - name: "registerCircuitVerifierAddresses", - type: "address[]", + internalType: "address", + name: "", + type: "address", }, + ], + stateMutability: "view", + type: "function", + }, + { + inputs: [ { - internalType: "uint256[]", - name: "dscCircuitVerifierIds", - type: "uint256[]", + components: [ + { + internalType: "bool", + name: "olderThanEnabled", + type: "bool", + }, + { + internalType: "uint256", + name: "olderThan", + type: "uint256", + }, + { + internalType: "bool", + name: "forbiddenCountriesEnabled", + type: "bool", + }, + { + internalType: "uint256[4]", + name: "forbiddenCountriesListPacked", + type: "uint256[4]", + }, + { + internalType: "bool[3]", + name: "ofacEnabled", + type: "bool[3]", + }, + ], + internalType: "struct SelfStructs.VerificationConfigV2", + name: "config", + type: "tuple", }, + ], + name: "generateConfigId", + outputs: [ { - internalType: "address[]", - name: "dscCircuitVerifierAddresses", - type: "address[]", + internalType: "bytes32", + name: "", + type: "bytes32", }, ], + stateMutability: "pure", + type: "function", + }, + { + inputs: [ + { + internalType: "bytes32", + name: "attestationId", + type: "bytes32", + }, + ], + name: "getIdentityCommitmentMerkleRoot", + outputs: [ + { + internalType: "uint256", + name: "", + type: "uint256", + }, + ], + stateMutability: "view", + type: "function", + }, + { + inputs: [], name: "initialize", outputs: [], stateMutability: "nonpayable", @@ -521,6 +611,30 @@ const _abi = [ stateMutability: "view", type: "function", }, + { + inputs: [ + { + internalType: "bytes32", + name: "attestationId", + type: "bytes32", + }, + { + internalType: "uint256", + name: "typeId", + type: "uint256", + }, + ], + name: "registerCircuitVerifiers", + outputs: [ + { + internalType: "address", + name: "", + type: "address", + }, + ], + stateMutability: "view", + type: "function", + }, { inputs: [ { @@ -639,18 +753,23 @@ const _abi = [ }, { inputs: [ + { + internalType: "bytes32", + name: "attestationId", + type: "bytes32", + }, { internalType: "uint256", - name: "typeId", + name: "root", type: "uint256", }, ], - name: "sigTypeToDscCircuitVerifiers", + name: "rootTimestamp", outputs: [ { - internalType: "address", + internalType: "uint256", name: "", - type: "address", + type: "uint256", }, ], stateMutability: "view", @@ -659,20 +778,47 @@ const _abi = [ { inputs: [ { - internalType: "uint256", - name: "typeId", - type: "uint256", + components: [ + { + internalType: "bool", + name: "olderThanEnabled", + type: "bool", + }, + { + internalType: "uint256", + name: "olderThan", + type: "uint256", + }, + { + internalType: "bool", + name: "forbiddenCountriesEnabled", + type: "bool", + }, + { + internalType: "uint256[4]", + name: "forbiddenCountriesListPacked", + type: "uint256[4]", + }, + { + internalType: "bool[3]", + name: "ofacEnabled", + type: "bool[3]", + }, + ], + internalType: "struct SelfStructs.VerificationConfigV2", + name: "config", + type: "tuple", }, ], - name: "sigTypeToRegisterCircuitVerifiers", + name: "setVerificationConfigV2", outputs: [ { - internalType: "address", - name: "", - type: "address", + internalType: "bytes32", + name: "configId", + type: "bytes32", }, ], - stateMutability: "view", + stateMutability: "nonpayable", type: "function", }, { @@ -690,6 +836,11 @@ const _abi = [ }, { inputs: [ + { + internalType: "bytes32", + name: "attestationId", + type: "bytes32", + }, { internalType: "uint256", name: "typeId", @@ -708,6 +859,11 @@ const _abi = [ }, { inputs: [ + { + internalType: "bytes32", + name: "attestationId", + type: "bytes32", + }, { internalType: "uint256", name: "typeId", @@ -782,16 +938,16 @@ const _abi = [ inputs: [ { internalType: "bytes32", - name: "attestationId", + name: "configId", type: "bytes32", }, ], - name: "vcAndDiscloseCircuitVerifier", + name: "verificationConfigV2Exists", outputs: [ { - internalType: "address", - name: "", - type: "address", + internalType: "bool", + name: "exists", + type: "bool", }, ], stateMutability: "view", @@ -801,19 +957,18 @@ const _abi = [ inputs: [ { internalType: "bytes", - name: "proofData", + name: "baseVerificationInput", type: "bytes", }, - ], - name: "verifyVcAndDisclose", - outputs: [ { internalType: "bytes", - name: "result", + name: "userContextData", type: "bytes", }, ], - stateMutability: "view", + name: "verify", + outputs: [], + stateMutability: "nonpayable", type: "function", }, ] as const; diff --git a/sdk/core/src/typechain-types/factories/Registry__factory.ts b/sdk/core/src/typechain-types/factories/Registry__factory.ts new file mode 100644 index 000000000..3ef7941ea --- /dev/null +++ b/sdk/core/src/typechain-types/factories/Registry__factory.ts @@ -0,0 +1,38 @@ +/* Autogenerated file. Do not edit manually. */ +/* tslint:disable */ +/* eslint-disable */ + +import { Contract, Interface, type ContractRunner } from "ethers"; +import type { Registry, RegistryInterface } from "../Registry.js"; + +const _abi = [ + { + inputs: [ + { + internalType: "uint256", + name: "root", + type: "uint256", + }, + ], + name: "checkIdentityCommitmentRoot", + outputs: [ + { + internalType: "bool", + name: "", + type: "bool", + }, + ], + stateMutability: "view", + type: "function", + }, +] as const; + +export class Registry__factory { + static readonly abi = _abi; + static createInterface(): RegistryInterface { + return new Interface(_abi) as RegistryInterface; + } + static connect(address: string, runner?: ContractRunner | null): Registry { + return new Contract(address, _abi, runner) as unknown as Registry; + } +} diff --git a/sdk/core/src/typechain-types/factories/Verifier__factory.ts b/sdk/core/src/typechain-types/factories/Verifier__factory.ts new file mode 100644 index 000000000..5e2c19f38 --- /dev/null +++ b/sdk/core/src/typechain-types/factories/Verifier__factory.ts @@ -0,0 +1,53 @@ +/* Autogenerated file. Do not edit manually. */ +/* tslint:disable */ +/* eslint-disable */ + +import { Contract, Interface, type ContractRunner } from "ethers"; +import type { Verifier, VerifierInterface } from "../Verifier.js"; + +const _abi = [ + { + inputs: [ + { + internalType: "uint256[2]", + name: "a", + type: "uint256[2]", + }, + { + internalType: "uint256[2][2]", + name: "b", + type: "uint256[2][2]", + }, + { + internalType: "uint256[2]", + name: "c", + type: "uint256[2]", + }, + { + internalType: "uint256[21]", + name: "pubSignals", + type: "uint256[21]", + }, + ], + name: "verifyProof", + outputs: [ + { + internalType: "bool", + name: "", + type: "bool", + }, + ], + stateMutability: "view", + type: "function", + }, +] as const; + +export class Verifier__factory { + static readonly abi = _abi; + static createInterface(): VerifierInterface { + return new Interface(_abi) as VerifierInterface; + } + static connect(address: string, runner?: ContractRunner | null): Verifier { + return new Contract(address, _abi, runner) as unknown as Verifier; + } +} diff --git a/sdk/core/src/typechain-types/factories/index.ts b/sdk/core/src/typechain-types/factories/index.ts index d16d52dfd..8407f83a7 100644 --- a/sdk/core/src/typechain-types/factories/index.ts +++ b/sdk/core/src/typechain-types/factories/index.ts @@ -2,3 +2,5 @@ /* tslint:disable */ /* eslint-disable */ export { IdentityVerificationHubImpl__factory } from "./IdentityVerificationHubImpl__factory.js"; +export { Registry__factory } from "./Registry__factory.js"; +export { Verifier__factory } from "./Verifier__factory.js"; diff --git a/sdk/core/src/typechain-types/index.ts b/sdk/core/src/typechain-types/index.ts index 49e0c61d3..9f484a67b 100644 --- a/sdk/core/src/typechain-types/index.ts +++ b/sdk/core/src/typechain-types/index.ts @@ -2,5 +2,9 @@ /* tslint:disable */ /* eslint-disable */ export type { IdentityVerificationHubImpl } from "./IdentityVerificationHubImpl.js"; +export type { Registry } from "./Registry.js"; +export type { Verifier } from "./Verifier.js"; export * as factories from "./factories/index.js"; export { IdentityVerificationHubImpl__factory } from "./factories/IdentityVerificationHubImpl__factory.js"; +export { Registry__factory } from "./factories/Registry__factory.js"; +export { Verifier__factory } from "./factories/Verifier__factory.js"; diff --git a/sdk/core/src/types/types.ts b/sdk/core/src/types/types.ts index 1807856dd..3cbfbd3b9 100644 --- a/sdk/core/src/types/types.ts +++ b/sdk/core/src/types/types.ts @@ -1,4 +1,5 @@ import type { BigNumberish } from 'ethers'; +import type { SelfStructs } from '../typechain-types/IdentityVerificationHubImpl.js'; export type VcAndDiscloseProof = { a: [BigNumberish, BigNumberish]; @@ -7,7 +8,6 @@ export type VcAndDiscloseProof = { pubSignals: BigNumberish[]; }; -// export type VerificationConfig = +export type VerificationConfig = SelfStructs.VerificationConfigV2Struct; -interface IConfigStorage { -} +export type GenericDiscloseStruct = SelfStructs.VerificationConfigV2Struct; diff --git a/sdk/core/src/utils/constants.ts b/sdk/core/src/utils/constants.ts new file mode 100644 index 000000000..9c383bcbd --- /dev/null +++ b/sdk/core/src/utils/constants.ts @@ -0,0 +1,75 @@ +export const discloseIndices = { + 1: { + revealedDataPackedIndex: 0, + forbiddenCountriesListPackedIndex: 3, + nullifierIndex: 7, + attestationIdIndex: 8, + merkleRootIndex: 9, + currentDateIndex: 10, + namedobSmtRootIndex: 17, + nameyobSmtRootIndex: 18, + scopeIndex: 19, + userIdentifierIndex: 20, + passportNoSmtRootIndex: 16, + }, + 2: { + revealedDataPackedIndex: 0, + forbiddenCountriesListPackedIndex: 4, + nullifierIndex: 8, + attestationIdIndex: 9, + merkleRootIndex: 10, + currentDateIndex: 11, + namedobSmtRootIndex: 17, + nameyobSmtRootIndex: 18, + scopeIndex: 19, + userIdentifierIndex: 20, + passportNoSmtRootIndex: 99, + } +} as const; + +type RevealedDataFields = 'issuingState' | 'name' | 'idNumber' | 'nationality' | 'dateOfBirth' | 'gender' | 'expiryDate' | 'olderThan' | 'ofac'; + +export const revealedDataIndices: Record> = { + 1: { + issuingStateStart: 2, + issuingStateEnd: 4, + nameStart: 5, + nameEnd: 43, + idNumberStart: 44, + idNumberEnd: 52, + nationalityStart: 54, + nationalityEnd: 56, + dateOfBirthStart: 57, + dateOfBirthEnd: 62, + genderStart: 64, + genderEnd: 64, + expiryDateStart: 65, + expiryDateEnd: 70, + olderThanStart: 88, + olderThanEnd: 89, + ofacStart: 90, + ofacEnd: 92, + }, + 2: { + issuingStateStart: 2, + issuingStateEnd: 4, + nameStart: 60, + nameEnd: 89, + idNumberStart: 5, + idNumberEnd: 13, + nationalityStart: 45, + nationalityEnd: 47, + dateOfBirthStart: 30, + dateOfBirthEnd: 35, + genderStart: 37, + genderEnd: 37, + expiryDateStart: 38, + expiryDateEnd: 43, + olderThanStart: 90, + olderThanEnd: 91, + ofacStart: 92, + ofacEnd: 93, + } +} as const; + +export type AttestationId = keyof typeof discloseIndices; diff --git a/sdk/core/src/utils/hash.ts b/sdk/core/src/utils/hash.ts new file mode 100644 index 000000000..8d48d35d3 --- /dev/null +++ b/sdk/core/src/utils/hash.ts @@ -0,0 +1,9 @@ +import { createHash } from "crypto"; + +export function calculateUserIdentifierHash(userContextData: string): string { + const sha256Hash = createHash("sha256") + .update(Buffer.from(userContextData.slice(2), "hex")) + .digest(); + const ripemdHash = createHash("ripemd160").update(sha256Hash).digest(); + return "0x" + ripemdHash.toString("hex").padStart(40, "0"); +} diff --git a/sdk/core/src/utils/id.ts b/sdk/core/src/utils/id.ts new file mode 100644 index 000000000..5c60cb45b --- /dev/null +++ b/sdk/core/src/utils/id.ts @@ -0,0 +1,48 @@ +import { AttestationId, discloseIndices, revealedDataIndices } from "./constants.js"; +import { getRevealedDataBytes } from "./proof.js"; + + +export const formatRevealedDataPacked = (attestationId: AttestationId, publicSignals: string[]): GenericDiscloseOutput => { + const revealedDataPacked = getRevealedDataBytes(attestationId, publicSignals); + const revealedDataPackedString = Buffer.from(revealedDataPacked); + + const nullifier = publicSignals[discloseIndices[attestationId].nullifierIndex]; + const forbiddenCountriesListPacked = publicSignals.slice(discloseIndices[attestationId].forbiddenCountriesListPackedIndex, discloseIndices[attestationId].forbiddenCountriesListPackedIndex + 3); + const issuingState = revealedDataPackedString.subarray(revealedDataIndices[attestationId].issuingStateStart, revealedDataIndices[attestationId].issuingStateEnd + 1).toString("utf-8"); + const name = revealedDataPackedString.subarray(revealedDataIndices[attestationId].nameStart, revealedDataIndices[attestationId].nameEnd + 1).toString("utf-8").replace("<<", " ").replace(/<*/g, ""); + const idNumber = revealedDataPackedString.subarray(revealedDataIndices[attestationId].idNumberStart, revealedDataIndices[attestationId].idNumberEnd + 1).toString("utf-8"); + const nationality = revealedDataPackedString.subarray(revealedDataIndices[attestationId].nationalityStart, revealedDataIndices[attestationId].nationalityEnd + 1).toString("utf-8"); + const dateOfBirth = revealedDataPackedString.subarray(revealedDataIndices[attestationId].dateOfBirthStart, revealedDataIndices[attestationId].dateOfBirthEnd + 1).toString("utf-8"); + const gender = revealedDataPackedString.subarray(revealedDataIndices[attestationId].genderStart, revealedDataIndices[attestationId].genderEnd + 1).toString("utf-8"); + const expiryDate = revealedDataPackedString.subarray(revealedDataIndices[attestationId].expiryDateStart, revealedDataIndices[attestationId].expiryDateEnd + 1).toString("utf-8"); + const olderThan = revealedDataPackedString.subarray(revealedDataIndices[attestationId].olderThanStart, revealedDataIndices[attestationId].olderThanEnd + 1).toString("utf-8"); + const ofac = Array.from(revealedDataPackedString.subarray(revealedDataIndices[attestationId].ofacStart, revealedDataIndices[attestationId].ofacEnd + 1)).map(Boolean); + + return { + nullifier: nullifier.toString(), + forbiddenCountriesListPacked: forbiddenCountriesListPacked, + issuingState: issuingState, + name: name, + idNumber: idNumber, + nationality: nationality, + dateOfBirth: dateOfBirth, + gender: gender, + expiryDate: expiryDate, + olderThan: olderThan, + ofac: ofac, + } +}; + +type GenericDiscloseOutput = { + nullifier: string; + forbiddenCountriesListPacked: string[]; + issuingState: string; + name: string; + idNumber: string; + nationality: string; + dateOfBirth: string; + gender: string; + expiryDate: string; + olderThan: string; + ofac: boolean[]; +} diff --git a/sdk/core/src/utils/proof.ts b/sdk/core/src/utils/proof.ts new file mode 100644 index 000000000..efcfc1b79 --- /dev/null +++ b/sdk/core/src/utils/proof.ts @@ -0,0 +1,42 @@ +import { PublicSignals } from 'snarkjs'; +import { AttestationId, discloseIndices } from './constants.js'; + +export function getRevealedDataPublicSignalsLength(attestationId: AttestationId): number { + switch (attestationId) { + case 1: + return 93 / 31; + case 2: + return Math.ceil(94 / 31); + default: + throw new Error(`Invalid attestation ID: ${attestationId}`); + } +} + +export const bytesCount: Record = { + 1: [31, 31, 31], + 2: [31, 31, 31, 1], +}; + +export function getRevealedDataBytes(attestationId: AttestationId, publicSignals: PublicSignals): number[] { + let bytes: number[] = []; + for (let i = 0; i < getRevealedDataPublicSignalsLength(attestationId); i++) { + let publicSignal = BigInt(publicSignals[discloseIndices[attestationId].revealedDataPackedIndex + i]); + for (let j = 0; j < bytesCount[attestationId][i]; j++) { + bytes.push(Number(publicSignal & 0xffn)); + publicSignal = publicSignal >> 8n; + } + } + console.log(bytes); + + return bytes; +} + +// export async function getUserIdentifier( +// publicSignals: PublicSignals, +// user_identifier_type: UserIdType = 'uuid' +// ): Promise { +// return castToUserIdentifier( +// BigInt(publicSignals[CIRCUIT_CONSTANTS.VC_AND_DISCLOSE_USER_IDENTIFIER_INDEX]), +// user_identifier_type +// ); +// } diff --git a/sdk/core/src/utils/utils.ts b/sdk/core/src/utils/utils.ts index 28ac6a549..5385aa87b 100644 --- a/sdk/core/src/utils/utils.ts +++ b/sdk/core/src/utils/utils.ts @@ -1,28 +1,34 @@ -import { CIRCUIT_CONSTANTS } from '@selfxyz/common'; -import { castToUserIdentifier, UserIdType } from '@selfxyz/common/utils/circuits/uuid'; -import { BigNumberish } from 'ethers'; -import { PublicSignals } from 'snarkjs'; +export function unpackReveal( + revealedData_packed: string | string[], + id_type: 'passport' | 'id' +): string[] { + // If revealedData_packed is not an array, convert it to an array + const packedArray = Array.isArray(revealedData_packed) + ? revealedData_packed + : [revealedData_packed]; -export function parseSolidityCalldata(rawCallData: string, _type: T): T { - const parsed = JSON.parse('[' + rawCallData + ']'); + const bytesCount = id_type === 'passport' ? [31, 31, 31] : [31, 31, 31, 27]; // nb of bytes in each of the first three field elements + const bytesArray = packedArray.flatMap((element: string, index: number) => { + const bytes = bytesCount[index] || 31; // Use 31 as default if index is out of range + const elementBigInt = BigInt(element); + const byteMask = BigInt(255); // 0xFF + const bytesOfElement = [...Array(bytes)].map((_, byteIndex) => { + return (elementBigInt >> (BigInt(byteIndex) * BigInt(8))) & byteMask; + }); + return bytesOfElement; + }); - return { - a: parsed[0].map((x: string) => x.replace(/"/g, '')) as [BigNumberish, BigNumberish], - b: parsed[1].map((arr: string[]) => arr.map((x: string) => x.replace(/"/g, ''))) as [ - [BigNumberish, BigNumberish], - [BigNumberish, BigNumberish], - ], - c: parsed[2].map((x: string) => x.replace(/"/g, '')) as [BigNumberish, BigNumberish], - pubSignals: parsed[3].map((x: string) => x.replace(/"/g, '')) as BigNumberish[], - } as T; + return bytesArray.map((byte: bigint) => String.fromCharCode(Number(byte))); } -export async function getUserIdentifier( - publicSignals: PublicSignals, - user_identifier_type: UserIdType = 'uuid' -): Promise { - return castToUserIdentifier( - BigInt(publicSignals[CIRCUIT_CONSTANTS.VC_AND_DISCLOSE_USER_IDENTIFIER_INDEX]), - user_identifier_type - ); +export function unpackForbiddenCountriesList(forbiddenCountriesList_packed: string[]) { + const trimmed = unpackReveal(forbiddenCountriesList_packed, 'id'); + const countries = []; + for (let i = 0; i < trimmed.length; i += 3) { + const countryCode = trimmed.slice(i, i + 3).join(''); + if (countryCode.length === 3) { + countries.push(countryCode); + } + } + return countries; // Return countries array instead of trimmed } From 59bfc7bb7cdb458d1e46fb5cd049de4df95d6086 Mon Sep 17 00:00:00 2001 From: Ayman Date: Fri, 20 Jun 2025 19:51:49 +0530 Subject: [PATCH 04/25] feat: consider destination chain in user defined data --- sdk/core/src/SelfBackendVerifier.ts | 94 +---------------------------- sdk/core/src/utils/hash.ts | 4 +- 2 files changed, 5 insertions(+), 93 deletions(-) diff --git a/sdk/core/src/SelfBackendVerifier.ts b/sdk/core/src/SelfBackendVerifier.ts index bd5aa545e..8f0ae2cbc 100644 --- a/sdk/core/src/SelfBackendVerifier.ts +++ b/sdk/core/src/SelfBackendVerifier.ts @@ -54,7 +54,7 @@ export class SelfBackendVerifier { //check if user context hash matches const userContextHashInCircuit = publicSignals[discloseIndices[attestationId].userIdentifierIndex]; - const userContextHash = calculateUserIdentifierHash(userContextData); + const userContextHash = calculateUserIdentifierHash(Buffer.from(userContextData, "hex")); if (userContextHashInCircuit !== userContextHash) { issues.push({ type: ConfigMismatch.InvalidUserContextHash, message: 'User context hash does not match with the one in the circuit' }); @@ -72,9 +72,7 @@ export class SelfBackendVerifier { if (registryAddress === '0x0000000000000000000000000000000000000000') { throw new Error('Registry contract not found'); } - console.log('registryAddress', registryAddress); const registryContract = Registry__factory.connect(registryAddress, this.provider); - console.log('publicSignals[discloseIndices[attestationId].merkleRootIndex]', publicSignals[discloseIndices[attestationId].merkleRootIndex]); const currentRoot = await registryContract.checkIdentityCommitmentRoot(publicSignals[discloseIndices[attestationId].merkleRootIndex]); if (!currentRoot) { issues.push({ type: ConfigMismatch.InvalidRoot, message: 'Onchain root does not match with the one in the circuit' }); @@ -89,8 +87,8 @@ export class SelfBackendVerifier { issues.push({ type: ConfigMismatch.InvalidAttestationId, message: 'Attestation ID does not match with the one in the circuit' }); } - const userIdentifier = castToUserIdentifier(BigInt(userContextData.slice(0, 32)), this.userIdentifierType); - const userDefinedData = userContextData.slice(32); + const userIdentifier = castToUserIdentifier(BigInt(userContextData.slice(64, 128)), this.userIdentifierType); + const userDefinedData = userContextData.slice(128); const configId = await this.configStorage.getActionId(userIdentifier, userDefinedData); const verificationConfig = await this.configStorage.getConfig(configId); @@ -147,7 +145,6 @@ export class SelfBackendVerifier { try { const verifierAddress = await this.identityVerificationHubContract.discloseVerifier('0x' + attestationId.toString(16).padStart(64, '0')); verifierContract = Verifier__factory.connect(verifierAddress, this.provider); - console.log('verifierAddress', verifierAddress); }catch (error) { throw new Error('Verifier contract not found'); } @@ -172,88 +169,3 @@ export class SelfBackendVerifier { } } } - -(async () => { - const allowedIds = new Map(); - allowedIds.set(1, true); - allowedIds.set(2, true); - const verifier = new SelfBackendVerifier('https://selfxyz.io', 'https://selfxyz.io', true, allowedIds, new DefaultConfigStore({ - olderThanEnabled: false, - olderThan: '18', - forbiddenCountriesEnabled: false, - forbiddenCountriesListPacked: [ - '0x414754414154414149414f4741444e414d5341415a44424c41414c41474641', - '0x4542524c42425242444742524842534842455a415355415742414d52414752', - '0x4e41434d484b5650434e52424c4f424e5442554d424e45425a4c42554d424c', - '0x4853454d4559424d5a45575a5455564b4e445453454e4843564943' - ], - ofacEnabled: [true, true, true] - }), 'uuid'); - - // await verifier.verify(1, { - // "a": ["20027747457384548915754048546300078359238644739611306732203396740377022269632", "2922252454334934814523912619336295865418779710963506663844841070040892368599"], - // "b": [ - // ["18550618272017193017683281599041714361177883341207882150042864009452803287635", "11835322382845835127938425066445170832745075061887634147517477198658857275684"], - // ["9589052941833010873145632477110100396776386222278078408779066519235765125504", "4446299920668248986575867643716084694453281451335382773821734541324874380964"]], - // "c": ["13869518253907120487751576221202706397626340056519243861474381557882676036567", "12690387074286053910397617351082313207917428545513560875234502132363926637665"], - // pubSignals: [ - // "0", - // "104974056514807040022473273876258729896969411582978218858119168", - // "1773781688717606310397756023428205332782362187156068670010833396561870848", - // "6818352527182560077653388211384938507686473", - // "0", - // "0", - // "0", - // "8393865390816338643283234268763358234972139160362896016192609318836495598412", - // "1", - // "12042122855944027015224247589071180050575929049407085527795781545283481922120", - // "2", - // "5", - // "0", - // "6", - // "1", - // "5", - // "17359956125106148146828355805271472653597249114301196742546733402427978706344", - // "7420120618403967585712321281997181302561301414016003514649937965499789236588", - // "16836358042995742879630198413873414945978677264752036026400967422611478610995", - // "20547922292487865646889398151624351195094737616498816569824986876525492837134", - // "32484638221990080388773097521078796272" - // ]}, - // "1234567890" - // ); - - await verifier.verify(2, - { - "a": ["12081211863281045519638435814320218331506181778260003189006684934781096301530", "8060260813032756056355953005294591165747245129871184047363247350832615678279"], - "b": [ - ["4347315068897320978820992945813773246810792668754558635019200272564387822377", "15752614222213378619781143491974874432941718433078511349040538945306489946483"], - ["21556638492815180585049800142968980107901950444515421443099323631356046322632", "3164272229051284860567978678792807807073207139807100212958388224608073319238"] - ], - "c": ["5267406348608997194371334102763008174473847620068385896652634372612077418468", "14110837162069354172999846461488917221179735837657004699809342354383332253012"], - pubSignals: [ - "0", - "22229121118744123602918790561256186052608", - "2154665897585346283029582512769695903067754219393865093262281634727591936", - "1", - "a6818352527182560077653388211384938507686473", - "0", - "0", - "0", - "12816268866992348722154762391251116294707511988403581258809971144485079648161", - "2", - "4473515946166166681112263978860717654366030938166274938260019677592087803375", - "2", - "5", - "0", - "6", - "1", - "7", - "20550865940766091336114076617084411967227963708544788410483208672684333597871", - "20607501071671444315195585339157145490348308593668944037177822930025980459166", - "13934606664243914063643606771911468856671016933765586820821710153612586828695", - "185590350843347269691547707205927446533" - ] - }, - "1234567890" - ); -})(); diff --git a/sdk/core/src/utils/hash.ts b/sdk/core/src/utils/hash.ts index 8d48d35d3..237713332 100644 --- a/sdk/core/src/utils/hash.ts +++ b/sdk/core/src/utils/hash.ts @@ -1,8 +1,8 @@ import { createHash } from "crypto"; -export function calculateUserIdentifierHash(userContextData: string): string { +export function calculateUserIdentifierHash(userContextData: Buffer): string { const sha256Hash = createHash("sha256") - .update(Buffer.from(userContextData.slice(2), "hex")) + .update(userContextData) .digest(); const ripemdHash = createHash("ripemd160").update(sha256Hash).digest(); return "0x" + ripemdHash.toString("hex").padStart(40, "0"); From 45c631ca05856b5130f357ad4f62560c2df63c57 Mon Sep 17 00:00:00 2001 From: Ayman Date: Fri, 20 Jun 2025 20:31:57 +0530 Subject: [PATCH 05/25] chore: export attestation id --- sdk/core/index.ts | 1 + sdk/core/src/SelfBackendVerifier.ts | 4 ++-- sdk/core/src/types/types.ts | 3 +++ sdk/core/src/utils/constants.ts | 4 ++-- 4 files changed, 8 insertions(+), 4 deletions(-) diff --git a/sdk/core/index.ts b/sdk/core/index.ts index a49ec7db8..10f55d2e4 100644 --- a/sdk/core/index.ts +++ b/sdk/core/index.ts @@ -5,6 +5,7 @@ export type { SelfApp } from '@selfxyz/common/utils/appType'; import { countries } from '@selfxyz/common'; import { hashEndpointWithScope } from '@selfxyz/common/utils/scope'; import { getPackedForbiddenCountries } from '@selfxyz/common/utils/contracts/forbiddenCountries'; +import type { AttestationId } from 'src/types/types.js'; export { SelfBackendVerifier, diff --git a/sdk/core/src/SelfBackendVerifier.ts b/sdk/core/src/SelfBackendVerifier.ts index 8f0ae2cbc..fe0d89313 100644 --- a/sdk/core/src/SelfBackendVerifier.ts +++ b/sdk/core/src/SelfBackendVerifier.ts @@ -1,9 +1,9 @@ import { ethers } from 'ethers'; import { hashEndpointWithScope } from '@selfxyz/common/utils/scope'; import { IdentityVerificationHubImpl, IdentityVerificationHubImpl__factory, Registry__factory, Verifier, Verifier__factory } from './typechain-types/index.js'; -import { AttestationId, discloseIndices } from './utils/constants.js'; +import { discloseIndices } from './utils/constants.js'; import { formatRevealedDataPacked } from './utils/id.js'; -import { VcAndDiscloseProof } from './types/types.js'; +import { AttestationId, VcAndDiscloseProof } from './types/types.js'; import { Country3LetterCode } from '@selfxyz/common'; import { calculateUserIdentifierHash } from './utils/hash.js'; import { castToUserIdentifier, UserIdType } from '@selfxyz/common/utils/circuits/uuid'; diff --git a/sdk/core/src/types/types.ts b/sdk/core/src/types/types.ts index 3cbfbd3b9..50f554672 100644 --- a/sdk/core/src/types/types.ts +++ b/sdk/core/src/types/types.ts @@ -1,5 +1,6 @@ import type { BigNumberish } from 'ethers'; import type { SelfStructs } from '../typechain-types/IdentityVerificationHubImpl.js'; +import { discloseIndices } from 'src/utils/constants.js'; export type VcAndDiscloseProof = { a: [BigNumberish, BigNumberish]; @@ -11,3 +12,5 @@ export type VcAndDiscloseProof = { export type VerificationConfig = SelfStructs.VerificationConfigV2Struct; export type GenericDiscloseStruct = SelfStructs.VerificationConfigV2Struct; + +export type AttestationId = keyof typeof discloseIndices; diff --git a/sdk/core/src/utils/constants.ts b/sdk/core/src/utils/constants.ts index 9c383bcbd..cd89947a6 100644 --- a/sdk/core/src/utils/constants.ts +++ b/sdk/core/src/utils/constants.ts @@ -1,3 +1,5 @@ +import { AttestationId } from "src/types/types.js"; + export const discloseIndices = { 1: { revealedDataPackedIndex: 0, @@ -71,5 +73,3 @@ export const revealedDataIndices: Record Date: Fri, 20 Jun 2025 20:33:53 +0530 Subject: [PATCH 06/25] chore: export attestation id --- sdk/core/index.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/sdk/core/index.ts b/sdk/core/index.ts index 10f55d2e4..ee44be5ca 100644 --- a/sdk/core/index.ts +++ b/sdk/core/index.ts @@ -15,4 +15,5 @@ export { hashEndpointWithScope, SelfAppBuilder, getPackedForbiddenCountries, + AttestationId }; From 576065585bb24747983ae77b253787dc25615f6e Mon Sep 17 00:00:00 2001 From: Ayman Date: Fri, 20 Jun 2025 20:38:10 +0530 Subject: [PATCH 07/25] chore: export config storage --- sdk/core/index.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/sdk/core/index.ts b/sdk/core/index.ts index ee44be5ca..97c76f4cb 100644 --- a/sdk/core/index.ts +++ b/sdk/core/index.ts @@ -6,6 +6,8 @@ import { countries } from '@selfxyz/common'; import { hashEndpointWithScope } from '@selfxyz/common/utils/scope'; import { getPackedForbiddenCountries } from '@selfxyz/common/utils/contracts/forbiddenCountries'; import type { AttestationId } from 'src/types/types.js'; +import type { IConfigStorage } from 'src/store/interface.js'; +import { DefaultConfigStore } from 'src/store/DefaultConfigStore.js'; export { SelfBackendVerifier, @@ -15,5 +17,7 @@ export { hashEndpointWithScope, SelfAppBuilder, getPackedForbiddenCountries, - AttestationId + AttestationId, + IConfigStorage, + DefaultConfigStore }; From dbc3255e4cb46efa4c82b3d7b87fc15a090882ae Mon Sep 17 00:00:00 2001 From: Ayman Date: Fri, 20 Jun 2025 20:41:59 +0530 Subject: [PATCH 08/25] chore: don't throw an error if the proof is not valid --- sdk/core/src/SelfBackendVerifier.ts | 7 +------ sdk/core/src/errors.ts | 16 ---------------- 2 files changed, 1 insertion(+), 22 deletions(-) diff --git a/sdk/core/src/SelfBackendVerifier.ts b/sdk/core/src/SelfBackendVerifier.ts index fe0d89313..40e315526 100644 --- a/sdk/core/src/SelfBackendVerifier.ts +++ b/sdk/core/src/SelfBackendVerifier.ts @@ -7,8 +7,7 @@ import { AttestationId, VcAndDiscloseProof } from './types/types.js'; import { Country3LetterCode } from '@selfxyz/common'; import { calculateUserIdentifierHash } from './utils/hash.js'; import { castToUserIdentifier, UserIdType } from '@selfxyz/common/utils/circuits/uuid'; -import { ConfigMismatch, ConfigMismatchError, InvalidProof, InvalidProofError } from './errors.js'; -import { DefaultConfigStore } from './store/DefaultConfigStore.js'; +import { ConfigMismatch, ConfigMismatchError } from './errors.js'; import { IConfigStorage } from './store/interface.js'; import { unpackForbiddenCountriesList } from './utils/utils.js'; @@ -154,10 +153,6 @@ export class SelfBackendVerifier { [proof.b[1][1], proof.b[1][0]], ], proof.c, publicSignals); - if (!isValid) { - throw new InvalidProofError(InvalidProof.InvalidProof, 'Proof is invalid'); - } - return { isValid, discloseOutput: genericDiscloseOutput, diff --git a/sdk/core/src/errors.ts b/sdk/core/src/errors.ts index 715065ebd..11e1118ac 100644 --- a/sdk/core/src/errors.ts +++ b/sdk/core/src/errors.ts @@ -26,19 +26,3 @@ export class ConfigMismatchError extends Error { return new ConfigMismatchError([{ type, message }]); } } - -export enum InvalidProof { - InvalidProof = 'InvalidProof', -} - -export class InvalidProofError extends Error { - public readonly type: InvalidProof; - - constructor(type: InvalidProof, message: string) { - super(`[${type}]: ${message}`); - this.name = 'InvalidProofError'; - this.type = type; - - Object.setPrototypeOf(this, InvalidProofError.prototype); - } -} From 601b35bb70af340e20f30a2693ead3ffba404dd1 Mon Sep 17 00:00:00 2001 From: Ayman Date: Fri, 20 Jun 2025 21:10:12 +0530 Subject: [PATCH 09/25] chore: trim abi and rm typechain types --- sdk/core/.gitignore | 3 +- .../contracts/IdentityVerificationHubImpl.ts | 886 -------------- sdk/core/app/contracts/common.ts | 131 --- .../IdentityVerificationHubImpl__factory.ts | 836 ------------- sdk/core/app/contracts/factories/index.ts | 4 - sdk/core/app/contracts/index.ts | 6 - sdk/core/package.json | 2 +- sdk/core/scripts/fix-imports.js | 26 - .../src/abi/IdentityVerificationHubImpl.json | 924 --------------- .../IdentityVerificationHubImpl.ts | 1040 ----------------- sdk/core/src/typechain-types/Registry.ts | 95 -- sdk/core/src/typechain-types/Verifier.ts | 114 -- sdk/core/src/typechain-types/common.ts | 131 --- .../IdentityVerificationHubImpl__factory.ts | 991 ---------------- .../factories/Registry__factory.ts | 38 - .../factories/Verifier__factory.ts | 53 - .../src/typechain-types/factories/index.ts | 6 - sdk/core/src/typechain-types/index.ts | 10 - sdk/core/src/utils/id.ts | 3 +- sdk/core/src/utils/proof.ts | 14 +- 20 files changed, 7 insertions(+), 5306 deletions(-) delete mode 100644 sdk/core/app/contracts/IdentityVerificationHubImpl.ts delete mode 100644 sdk/core/app/contracts/common.ts delete mode 100644 sdk/core/app/contracts/factories/IdentityVerificationHubImpl__factory.ts delete mode 100644 sdk/core/app/contracts/factories/index.ts delete mode 100644 sdk/core/app/contracts/index.ts delete mode 100644 sdk/core/scripts/fix-imports.js delete mode 100644 sdk/core/src/typechain-types/IdentityVerificationHubImpl.ts delete mode 100644 sdk/core/src/typechain-types/Registry.ts delete mode 100644 sdk/core/src/typechain-types/Verifier.ts delete mode 100644 sdk/core/src/typechain-types/common.ts delete mode 100644 sdk/core/src/typechain-types/factories/IdentityVerificationHubImpl__factory.ts delete mode 100644 sdk/core/src/typechain-types/factories/Registry__factory.ts delete mode 100644 sdk/core/src/typechain-types/factories/Verifier__factory.ts delete mode 100644 sdk/core/src/typechain-types/factories/index.ts delete mode 100644 sdk/core/src/typechain-types/index.ts diff --git a/sdk/core/.gitignore b/sdk/core/.gitignore index 99fc6008a..b58ed3cf9 100644 --- a/sdk/core/.gitignore +++ b/sdk/core/.gitignore @@ -1,4 +1,5 @@ node_modules/ +src/typechain-types/ yarn.lock yarn-error.log -dist \ No newline at end of file +dist diff --git a/sdk/core/app/contracts/IdentityVerificationHubImpl.ts b/sdk/core/app/contracts/IdentityVerificationHubImpl.ts deleted file mode 100644 index b4cf49f46..000000000 --- a/sdk/core/app/contracts/IdentityVerificationHubImpl.ts +++ /dev/null @@ -1,886 +0,0 @@ -/* Autogenerated file. Do not edit manually. */ -/* tslint:disable */ -/* eslint-disable */ -import type { - BaseContract, - BigNumberish, - BytesLike, - FunctionFragment, - Result, - Interface, - EventFragment, - AddressLike, - ContractRunner, - ContractMethod, - Listener, -} from "ethers"; -import type { - TypedContractEvent, - TypedDeferredTopicFilter, - TypedEventLog, - TypedLogDescription, - TypedListener, - TypedContractMethod, -} from "./common"; - -export declare namespace IRegisterCircuitVerifier { - export type RegisterCircuitProofStruct = { - a: [BigNumberish, BigNumberish]; - b: [[BigNumberish, BigNumberish], [BigNumberish, BigNumberish]]; - c: [BigNumberish, BigNumberish]; - pubSignals: [BigNumberish, BigNumberish, BigNumberish]; - }; - - export type RegisterCircuitProofStructOutput = [ - a: [bigint, bigint], - b: [[bigint, bigint], [bigint, bigint]], - c: [bigint, bigint], - pubSignals: [bigint, bigint, bigint] - ] & { - a: [bigint, bigint]; - b: [[bigint, bigint], [bigint, bigint]]; - c: [bigint, bigint]; - pubSignals: [bigint, bigint, bigint]; - }; -} - -export declare namespace IDscCircuitVerifier { - export type DscCircuitProofStruct = { - a: [BigNumberish, BigNumberish]; - b: [[BigNumberish, BigNumberish], [BigNumberish, BigNumberish]]; - c: [BigNumberish, BigNumberish]; - pubSignals: [BigNumberish, BigNumberish]; - }; - - export type DscCircuitProofStructOutput = [ - a: [bigint, bigint], - b: [[bigint, bigint], [bigint, bigint]], - c: [bigint, bigint], - pubSignals: [bigint, bigint] - ] & { - a: [bigint, bigint]; - b: [[bigint, bigint], [bigint, bigint]]; - c: [bigint, bigint]; - pubSignals: [bigint, bigint]; - }; -} - -export interface IdentityVerificationHubImplInterface extends Interface { - getFunction( - nameOrSignature: - | "UPGRADE_INTERFACE_VERSION" - | "acceptOwnership" - | "batchUpdateDscCircuitVerifiers" - | "batchUpdateRegisterCircuitVerifiers" - | "initialize" - | "owner" - | "pendingOwner" - | "proxiableUUID" - | "registerCommitment" - | "registerDscKeyCommitment" - | "registry" - | "renounceOwnership" - | "sigTypeToDscCircuitVerifiers" - | "sigTypeToRegisterCircuitVerifiers" - | "transferOwnership" - | "updateDscVerifier" - | "updateRegisterCircuitVerifier" - | "updateRegistry" - | "updateVcAndDiscloseCircuit" - | "upgradeToAndCall" - | "vcAndDiscloseCircuitVerifier" - | "verifyVcAndDisclose" - ): FunctionFragment; - - getEvent( - nameOrSignatureOrTopic: - | "DscCircuitVerifierUpdated" - | "HubInitialized" - | "Initialized" - | "OwnershipTransferStarted" - | "OwnershipTransferred" - | "RegisterCircuitVerifierUpdated" - | "RegistryUpdated" - | "Upgraded" - | "VcAndDiscloseCircuitUpdated" - ): EventFragment; - - encodeFunctionData( - functionFragment: "UPGRADE_INTERFACE_VERSION", - values?: undefined - ): string; - encodeFunctionData( - functionFragment: "acceptOwnership", - values?: undefined - ): string; - encodeFunctionData( - functionFragment: "batchUpdateDscCircuitVerifiers", - values: [BigNumberish[], AddressLike[]] - ): string; - encodeFunctionData( - functionFragment: "batchUpdateRegisterCircuitVerifiers", - values: [BigNumberish[], AddressLike[]] - ): string; - encodeFunctionData( - functionFragment: "initialize", - values: [ - BytesLike[], - AddressLike[], - AddressLike[], - BigNumberish[], - AddressLike[], - BigNumberish[], - AddressLike[] - ] - ): string; - encodeFunctionData(functionFragment: "owner", values?: undefined): string; - encodeFunctionData( - functionFragment: "pendingOwner", - values?: undefined - ): string; - encodeFunctionData( - functionFragment: "proxiableUUID", - values?: undefined - ): string; - encodeFunctionData( - functionFragment: "registerCommitment", - values: [ - BytesLike, - BigNumberish, - IRegisterCircuitVerifier.RegisterCircuitProofStruct - ] - ): string; - encodeFunctionData( - functionFragment: "registerDscKeyCommitment", - values: [BytesLike, BigNumberish, IDscCircuitVerifier.DscCircuitProofStruct] - ): string; - encodeFunctionData(functionFragment: "registry", values: [BytesLike]): string; - encodeFunctionData( - functionFragment: "renounceOwnership", - values?: undefined - ): string; - encodeFunctionData( - functionFragment: "sigTypeToDscCircuitVerifiers", - values: [BigNumberish] - ): string; - encodeFunctionData( - functionFragment: "sigTypeToRegisterCircuitVerifiers", - values: [BigNumberish] - ): string; - encodeFunctionData( - functionFragment: "transferOwnership", - values: [AddressLike] - ): string; - encodeFunctionData( - functionFragment: "updateDscVerifier", - values: [BigNumberish, AddressLike] - ): string; - encodeFunctionData( - functionFragment: "updateRegisterCircuitVerifier", - values: [BigNumberish, AddressLike] - ): string; - encodeFunctionData( - functionFragment: "updateRegistry", - values: [BytesLike, AddressLike] - ): string; - encodeFunctionData( - functionFragment: "updateVcAndDiscloseCircuit", - values: [BytesLike, AddressLike] - ): string; - encodeFunctionData( - functionFragment: "upgradeToAndCall", - values: [AddressLike, BytesLike] - ): string; - encodeFunctionData( - functionFragment: "vcAndDiscloseCircuitVerifier", - values: [BytesLike] - ): string; - encodeFunctionData( - functionFragment: "verifyVcAndDisclose", - values: [BytesLike] - ): string; - - decodeFunctionResult( - functionFragment: "UPGRADE_INTERFACE_VERSION", - data: BytesLike - ): Result; - decodeFunctionResult( - functionFragment: "acceptOwnership", - data: BytesLike - ): Result; - decodeFunctionResult( - functionFragment: "batchUpdateDscCircuitVerifiers", - data: BytesLike - ): Result; - decodeFunctionResult( - functionFragment: "batchUpdateRegisterCircuitVerifiers", - data: BytesLike - ): Result; - decodeFunctionResult(functionFragment: "initialize", data: BytesLike): Result; - decodeFunctionResult(functionFragment: "owner", data: BytesLike): Result; - decodeFunctionResult( - functionFragment: "pendingOwner", - data: BytesLike - ): Result; - decodeFunctionResult( - functionFragment: "proxiableUUID", - data: BytesLike - ): Result; - decodeFunctionResult( - functionFragment: "registerCommitment", - data: BytesLike - ): Result; - decodeFunctionResult( - functionFragment: "registerDscKeyCommitment", - data: BytesLike - ): Result; - decodeFunctionResult(functionFragment: "registry", data: BytesLike): Result; - decodeFunctionResult( - functionFragment: "renounceOwnership", - data: BytesLike - ): Result; - decodeFunctionResult( - functionFragment: "sigTypeToDscCircuitVerifiers", - data: BytesLike - ): Result; - decodeFunctionResult( - functionFragment: "sigTypeToRegisterCircuitVerifiers", - data: BytesLike - ): Result; - decodeFunctionResult( - functionFragment: "transferOwnership", - data: BytesLike - ): Result; - decodeFunctionResult( - functionFragment: "updateDscVerifier", - data: BytesLike - ): Result; - decodeFunctionResult( - functionFragment: "updateRegisterCircuitVerifier", - data: BytesLike - ): Result; - decodeFunctionResult( - functionFragment: "updateRegistry", - data: BytesLike - ): Result; - decodeFunctionResult( - functionFragment: "updateVcAndDiscloseCircuit", - data: BytesLike - ): Result; - decodeFunctionResult( - functionFragment: "upgradeToAndCall", - data: BytesLike - ): Result; - decodeFunctionResult( - functionFragment: "vcAndDiscloseCircuitVerifier", - data: BytesLike - ): Result; - decodeFunctionResult( - functionFragment: "verifyVcAndDisclose", - data: BytesLike - ): Result; -} - -export namespace DscCircuitVerifierUpdatedEvent { - export type InputTuple = [typeId: BigNumberish, verifier: AddressLike]; - export type OutputTuple = [typeId: bigint, verifier: string]; - export interface OutputObject { - typeId: bigint; - verifier: string; - } - export type Event = TypedContractEvent; - export type Filter = TypedDeferredTopicFilter; - export type Log = TypedEventLog; - export type LogDescription = TypedLogDescription; -} - -export namespace HubInitializedEvent { - export type InputTuple = [ - attestationIds: BytesLike[], - registryAddresses: AddressLike[], - vcAndDiscloseCircuitVerifiers: AddressLike[], - registerCircuitVerifierIds: BigNumberish[], - registerCircuitVerifiers: AddressLike[], - dscCircuitVerifierIds: BigNumberish[], - dscCircuitVerifiers: AddressLike[] - ]; - export type OutputTuple = [ - attestationIds: string[], - registryAddresses: string[], - vcAndDiscloseCircuitVerifiers: string[], - registerCircuitVerifierIds: bigint[], - registerCircuitVerifiers: string[], - dscCircuitVerifierIds: bigint[], - dscCircuitVerifiers: string[] - ]; - export interface OutputObject { - attestationIds: string[]; - registryAddresses: string[]; - vcAndDiscloseCircuitVerifiers: string[]; - registerCircuitVerifierIds: bigint[]; - registerCircuitVerifiers: string[]; - dscCircuitVerifierIds: bigint[]; - dscCircuitVerifiers: string[]; - } - export type Event = TypedContractEvent; - export type Filter = TypedDeferredTopicFilter; - export type Log = TypedEventLog; - export type LogDescription = TypedLogDescription; -} - -export namespace InitializedEvent { - export type InputTuple = [version: BigNumberish]; - export type OutputTuple = [version: bigint]; - export interface OutputObject { - version: bigint; - } - export type Event = TypedContractEvent; - export type Filter = TypedDeferredTopicFilter; - export type Log = TypedEventLog; - export type LogDescription = TypedLogDescription; -} - -export namespace OwnershipTransferStartedEvent { - export type InputTuple = [previousOwner: AddressLike, newOwner: AddressLike]; - export type OutputTuple = [previousOwner: string, newOwner: string]; - export interface OutputObject { - previousOwner: string; - newOwner: string; - } - export type Event = TypedContractEvent; - export type Filter = TypedDeferredTopicFilter; - export type Log = TypedEventLog; - export type LogDescription = TypedLogDescription; -} - -export namespace OwnershipTransferredEvent { - export type InputTuple = [previousOwner: AddressLike, newOwner: AddressLike]; - export type OutputTuple = [previousOwner: string, newOwner: string]; - export interface OutputObject { - previousOwner: string; - newOwner: string; - } - export type Event = TypedContractEvent; - export type Filter = TypedDeferredTopicFilter; - export type Log = TypedEventLog; - export type LogDescription = TypedLogDescription; -} - -export namespace RegisterCircuitVerifierUpdatedEvent { - export type InputTuple = [typeId: BigNumberish, verifier: AddressLike]; - export type OutputTuple = [typeId: bigint, verifier: string]; - export interface OutputObject { - typeId: bigint; - verifier: string; - } - export type Event = TypedContractEvent; - export type Filter = TypedDeferredTopicFilter; - export type Log = TypedEventLog; - export type LogDescription = TypedLogDescription; -} - -export namespace RegistryUpdatedEvent { - export type InputTuple = [attestationId: BytesLike, registry: AddressLike]; - export type OutputTuple = [attestationId: string, registry: string]; - export interface OutputObject { - attestationId: string; - registry: string; - } - export type Event = TypedContractEvent; - export type Filter = TypedDeferredTopicFilter; - export type Log = TypedEventLog; - export type LogDescription = TypedLogDescription; -} - -export namespace UpgradedEvent { - export type InputTuple = [implementation: AddressLike]; - export type OutputTuple = [implementation: string]; - export interface OutputObject { - implementation: string; - } - export type Event = TypedContractEvent; - export type Filter = TypedDeferredTopicFilter; - export type Log = TypedEventLog; - export type LogDescription = TypedLogDescription; -} - -export namespace VcAndDiscloseCircuitUpdatedEvent { - export type InputTuple = [ - attestationId: BytesLike, - vcAndDiscloseCircuitVerifier: AddressLike - ]; - export type OutputTuple = [ - attestationId: string, - vcAndDiscloseCircuitVerifier: string - ]; - export interface OutputObject { - attestationId: string; - vcAndDiscloseCircuitVerifier: string; - } - export type Event = TypedContractEvent; - export type Filter = TypedDeferredTopicFilter; - export type Log = TypedEventLog; - export type LogDescription = TypedLogDescription; -} - -export interface IdentityVerificationHubImpl extends BaseContract { - connect(runner?: ContractRunner | null): IdentityVerificationHubImpl; - waitForDeployment(): Promise; - - interface: IdentityVerificationHubImplInterface; - - queryFilter( - event: TCEvent, - fromBlockOrBlockhash?: string | number | undefined, - toBlock?: string | number | undefined - ): Promise>>; - queryFilter( - filter: TypedDeferredTopicFilter, - fromBlockOrBlockhash?: string | number | undefined, - toBlock?: string | number | undefined - ): Promise>>; - - on( - event: TCEvent, - listener: TypedListener - ): Promise; - on( - filter: TypedDeferredTopicFilter, - listener: TypedListener - ): Promise; - - once( - event: TCEvent, - listener: TypedListener - ): Promise; - once( - filter: TypedDeferredTopicFilter, - listener: TypedListener - ): Promise; - - listeners( - event: TCEvent - ): Promise>>; - listeners(eventName?: string): Promise>; - removeAllListeners( - event?: TCEvent - ): Promise; - - UPGRADE_INTERFACE_VERSION: TypedContractMethod<[], [string], "view">; - - acceptOwnership: TypedContractMethod<[], [void], "nonpayable">; - - batchUpdateDscCircuitVerifiers: TypedContractMethod< - [typeIds: BigNumberish[], verifierAddresses: AddressLike[]], - [void], - "nonpayable" - >; - - batchUpdateRegisterCircuitVerifiers: TypedContractMethod< - [typeIds: BigNumberish[], verifierAddresses: AddressLike[]], - [void], - "nonpayable" - >; - - initialize: TypedContractMethod< - [ - attestationIds: BytesLike[], - registryAddresses: AddressLike[], - vcAndDiscloseCircuitVerifierAddresses: AddressLike[], - registerCircuitVerifierIds: BigNumberish[], - registerCircuitVerifierAddresses: AddressLike[], - dscCircuitVerifierIds: BigNumberish[], - dscCircuitVerifierAddresses: AddressLike[] - ], - [void], - "nonpayable" - >; - - owner: TypedContractMethod<[], [string], "view">; - - pendingOwner: TypedContractMethod<[], [string], "view">; - - proxiableUUID: TypedContractMethod<[], [string], "view">; - - registerCommitment: TypedContractMethod< - [ - attestationId: BytesLike, - registerCircuitVerifierId: BigNumberish, - registerCircuitProof: IRegisterCircuitVerifier.RegisterCircuitProofStruct - ], - [void], - "nonpayable" - >; - - registerDscKeyCommitment: TypedContractMethod< - [ - attestationId: BytesLike, - dscCircuitVerifierId: BigNumberish, - dscCircuitProof: IDscCircuitVerifier.DscCircuitProofStruct - ], - [void], - "nonpayable" - >; - - registry: TypedContractMethod<[attestationId: BytesLike], [string], "view">; - - renounceOwnership: TypedContractMethod<[], [void], "nonpayable">; - - sigTypeToDscCircuitVerifiers: TypedContractMethod< - [typeId: BigNumberish], - [string], - "view" - >; - - sigTypeToRegisterCircuitVerifiers: TypedContractMethod< - [typeId: BigNumberish], - [string], - "view" - >; - - transferOwnership: TypedContractMethod< - [newOwner: AddressLike], - [void], - "nonpayable" - >; - - updateDscVerifier: TypedContractMethod< - [typeId: BigNumberish, verifierAddress: AddressLike], - [void], - "nonpayable" - >; - - updateRegisterCircuitVerifier: TypedContractMethod< - [typeId: BigNumberish, verifierAddress: AddressLike], - [void], - "nonpayable" - >; - - updateRegistry: TypedContractMethod< - [attestationId: BytesLike, registryAddress: AddressLike], - [void], - "nonpayable" - >; - - updateVcAndDiscloseCircuit: TypedContractMethod< - [ - attestationId: BytesLike, - vcAndDiscloseCircuitVerifierAddress: AddressLike - ], - [void], - "nonpayable" - >; - - upgradeToAndCall: TypedContractMethod< - [newImplementation: AddressLike, data: BytesLike], - [void], - "payable" - >; - - vcAndDiscloseCircuitVerifier: TypedContractMethod< - [attestationId: BytesLike], - [string], - "view" - >; - - verifyVcAndDisclose: TypedContractMethod< - [proofData: BytesLike], - [string], - "view" - >; - - getFunction( - key: string | FunctionFragment - ): T; - - getFunction( - nameOrSignature: "UPGRADE_INTERFACE_VERSION" - ): TypedContractMethod<[], [string], "view">; - getFunction( - nameOrSignature: "acceptOwnership" - ): TypedContractMethod<[], [void], "nonpayable">; - getFunction( - nameOrSignature: "batchUpdateDscCircuitVerifiers" - ): TypedContractMethod< - [typeIds: BigNumberish[], verifierAddresses: AddressLike[]], - [void], - "nonpayable" - >; - getFunction( - nameOrSignature: "batchUpdateRegisterCircuitVerifiers" - ): TypedContractMethod< - [typeIds: BigNumberish[], verifierAddresses: AddressLike[]], - [void], - "nonpayable" - >; - getFunction( - nameOrSignature: "initialize" - ): TypedContractMethod< - [ - attestationIds: BytesLike[], - registryAddresses: AddressLike[], - vcAndDiscloseCircuitVerifierAddresses: AddressLike[], - registerCircuitVerifierIds: BigNumberish[], - registerCircuitVerifierAddresses: AddressLike[], - dscCircuitVerifierIds: BigNumberish[], - dscCircuitVerifierAddresses: AddressLike[] - ], - [void], - "nonpayable" - >; - getFunction( - nameOrSignature: "owner" - ): TypedContractMethod<[], [string], "view">; - getFunction( - nameOrSignature: "pendingOwner" - ): TypedContractMethod<[], [string], "view">; - getFunction( - nameOrSignature: "proxiableUUID" - ): TypedContractMethod<[], [string], "view">; - getFunction( - nameOrSignature: "registerCommitment" - ): TypedContractMethod< - [ - attestationId: BytesLike, - registerCircuitVerifierId: BigNumberish, - registerCircuitProof: IRegisterCircuitVerifier.RegisterCircuitProofStruct - ], - [void], - "nonpayable" - >; - getFunction( - nameOrSignature: "registerDscKeyCommitment" - ): TypedContractMethod< - [ - attestationId: BytesLike, - dscCircuitVerifierId: BigNumberish, - dscCircuitProof: IDscCircuitVerifier.DscCircuitProofStruct - ], - [void], - "nonpayable" - >; - getFunction( - nameOrSignature: "registry" - ): TypedContractMethod<[attestationId: BytesLike], [string], "view">; - getFunction( - nameOrSignature: "renounceOwnership" - ): TypedContractMethod<[], [void], "nonpayable">; - getFunction( - nameOrSignature: "sigTypeToDscCircuitVerifiers" - ): TypedContractMethod<[typeId: BigNumberish], [string], "view">; - getFunction( - nameOrSignature: "sigTypeToRegisterCircuitVerifiers" - ): TypedContractMethod<[typeId: BigNumberish], [string], "view">; - getFunction( - nameOrSignature: "transferOwnership" - ): TypedContractMethod<[newOwner: AddressLike], [void], "nonpayable">; - getFunction( - nameOrSignature: "updateDscVerifier" - ): TypedContractMethod< - [typeId: BigNumberish, verifierAddress: AddressLike], - [void], - "nonpayable" - >; - getFunction( - nameOrSignature: "updateRegisterCircuitVerifier" - ): TypedContractMethod< - [typeId: BigNumberish, verifierAddress: AddressLike], - [void], - "nonpayable" - >; - getFunction( - nameOrSignature: "updateRegistry" - ): TypedContractMethod< - [attestationId: BytesLike, registryAddress: AddressLike], - [void], - "nonpayable" - >; - getFunction( - nameOrSignature: "updateVcAndDiscloseCircuit" - ): TypedContractMethod< - [ - attestationId: BytesLike, - vcAndDiscloseCircuitVerifierAddress: AddressLike - ], - [void], - "nonpayable" - >; - getFunction( - nameOrSignature: "upgradeToAndCall" - ): TypedContractMethod< - [newImplementation: AddressLike, data: BytesLike], - [void], - "payable" - >; - getFunction( - nameOrSignature: "vcAndDiscloseCircuitVerifier" - ): TypedContractMethod<[attestationId: BytesLike], [string], "view">; - getFunction( - nameOrSignature: "verifyVcAndDisclose" - ): TypedContractMethod<[proofData: BytesLike], [string], "view">; - - getEvent( - key: "DscCircuitVerifierUpdated" - ): TypedContractEvent< - DscCircuitVerifierUpdatedEvent.InputTuple, - DscCircuitVerifierUpdatedEvent.OutputTuple, - DscCircuitVerifierUpdatedEvent.OutputObject - >; - getEvent( - key: "HubInitialized" - ): TypedContractEvent< - HubInitializedEvent.InputTuple, - HubInitializedEvent.OutputTuple, - HubInitializedEvent.OutputObject - >; - getEvent( - key: "Initialized" - ): TypedContractEvent< - InitializedEvent.InputTuple, - InitializedEvent.OutputTuple, - InitializedEvent.OutputObject - >; - getEvent( - key: "OwnershipTransferStarted" - ): TypedContractEvent< - OwnershipTransferStartedEvent.InputTuple, - OwnershipTransferStartedEvent.OutputTuple, - OwnershipTransferStartedEvent.OutputObject - >; - getEvent( - key: "OwnershipTransferred" - ): TypedContractEvent< - OwnershipTransferredEvent.InputTuple, - OwnershipTransferredEvent.OutputTuple, - OwnershipTransferredEvent.OutputObject - >; - getEvent( - key: "RegisterCircuitVerifierUpdated" - ): TypedContractEvent< - RegisterCircuitVerifierUpdatedEvent.InputTuple, - RegisterCircuitVerifierUpdatedEvent.OutputTuple, - RegisterCircuitVerifierUpdatedEvent.OutputObject - >; - getEvent( - key: "RegistryUpdated" - ): TypedContractEvent< - RegistryUpdatedEvent.InputTuple, - RegistryUpdatedEvent.OutputTuple, - RegistryUpdatedEvent.OutputObject - >; - getEvent( - key: "Upgraded" - ): TypedContractEvent< - UpgradedEvent.InputTuple, - UpgradedEvent.OutputTuple, - UpgradedEvent.OutputObject - >; - getEvent( - key: "VcAndDiscloseCircuitUpdated" - ): TypedContractEvent< - VcAndDiscloseCircuitUpdatedEvent.InputTuple, - VcAndDiscloseCircuitUpdatedEvent.OutputTuple, - VcAndDiscloseCircuitUpdatedEvent.OutputObject - >; - - filters: { - "DscCircuitVerifierUpdated(uint256,address)": TypedContractEvent< - DscCircuitVerifierUpdatedEvent.InputTuple, - DscCircuitVerifierUpdatedEvent.OutputTuple, - DscCircuitVerifierUpdatedEvent.OutputObject - >; - DscCircuitVerifierUpdated: TypedContractEvent< - DscCircuitVerifierUpdatedEvent.InputTuple, - DscCircuitVerifierUpdatedEvent.OutputTuple, - DscCircuitVerifierUpdatedEvent.OutputObject - >; - - "HubInitialized(bytes32[],address[],address[],uint256[],address[],uint256[],address[])": TypedContractEvent< - HubInitializedEvent.InputTuple, - HubInitializedEvent.OutputTuple, - HubInitializedEvent.OutputObject - >; - HubInitialized: TypedContractEvent< - HubInitializedEvent.InputTuple, - HubInitializedEvent.OutputTuple, - HubInitializedEvent.OutputObject - >; - - "Initialized(uint64)": TypedContractEvent< - InitializedEvent.InputTuple, - InitializedEvent.OutputTuple, - InitializedEvent.OutputObject - >; - Initialized: TypedContractEvent< - InitializedEvent.InputTuple, - InitializedEvent.OutputTuple, - InitializedEvent.OutputObject - >; - - "OwnershipTransferStarted(address,address)": TypedContractEvent< - OwnershipTransferStartedEvent.InputTuple, - OwnershipTransferStartedEvent.OutputTuple, - OwnershipTransferStartedEvent.OutputObject - >; - OwnershipTransferStarted: TypedContractEvent< - OwnershipTransferStartedEvent.InputTuple, - OwnershipTransferStartedEvent.OutputTuple, - OwnershipTransferStartedEvent.OutputObject - >; - - "OwnershipTransferred(address,address)": TypedContractEvent< - OwnershipTransferredEvent.InputTuple, - OwnershipTransferredEvent.OutputTuple, - OwnershipTransferredEvent.OutputObject - >; - OwnershipTransferred: TypedContractEvent< - OwnershipTransferredEvent.InputTuple, - OwnershipTransferredEvent.OutputTuple, - OwnershipTransferredEvent.OutputObject - >; - - "RegisterCircuitVerifierUpdated(uint256,address)": TypedContractEvent< - RegisterCircuitVerifierUpdatedEvent.InputTuple, - RegisterCircuitVerifierUpdatedEvent.OutputTuple, - RegisterCircuitVerifierUpdatedEvent.OutputObject - >; - RegisterCircuitVerifierUpdated: TypedContractEvent< - RegisterCircuitVerifierUpdatedEvent.InputTuple, - RegisterCircuitVerifierUpdatedEvent.OutputTuple, - RegisterCircuitVerifierUpdatedEvent.OutputObject - >; - - "RegistryUpdated(bytes32,address)": TypedContractEvent< - RegistryUpdatedEvent.InputTuple, - RegistryUpdatedEvent.OutputTuple, - RegistryUpdatedEvent.OutputObject - >; - RegistryUpdated: TypedContractEvent< - RegistryUpdatedEvent.InputTuple, - RegistryUpdatedEvent.OutputTuple, - RegistryUpdatedEvent.OutputObject - >; - - "Upgraded(address)": TypedContractEvent< - UpgradedEvent.InputTuple, - UpgradedEvent.OutputTuple, - UpgradedEvent.OutputObject - >; - Upgraded: TypedContractEvent< - UpgradedEvent.InputTuple, - UpgradedEvent.OutputTuple, - UpgradedEvent.OutputObject - >; - - "VcAndDiscloseCircuitUpdated(bytes32,address)": TypedContractEvent< - VcAndDiscloseCircuitUpdatedEvent.InputTuple, - VcAndDiscloseCircuitUpdatedEvent.OutputTuple, - VcAndDiscloseCircuitUpdatedEvent.OutputObject - >; - VcAndDiscloseCircuitUpdated: TypedContractEvent< - VcAndDiscloseCircuitUpdatedEvent.InputTuple, - VcAndDiscloseCircuitUpdatedEvent.OutputTuple, - VcAndDiscloseCircuitUpdatedEvent.OutputObject - >; - }; -} diff --git a/sdk/core/app/contracts/common.ts b/sdk/core/app/contracts/common.ts deleted file mode 100644 index 56b5f21e9..000000000 --- a/sdk/core/app/contracts/common.ts +++ /dev/null @@ -1,131 +0,0 @@ -/* Autogenerated file. Do not edit manually. */ -/* tslint:disable */ -/* eslint-disable */ -import type { - FunctionFragment, - Typed, - EventFragment, - ContractTransaction, - ContractTransactionResponse, - DeferredTopicFilter, - EventLog, - TransactionRequest, - LogDescription, -} from "ethers"; - -export interface TypedDeferredTopicFilter<_TCEvent extends TypedContractEvent> - extends DeferredTopicFilter {} - -export interface TypedContractEvent< - InputTuple extends Array = any, - OutputTuple extends Array = any, - OutputObject = any -> { - (...args: Partial): TypedDeferredTopicFilter< - TypedContractEvent - >; - name: string; - fragment: EventFragment; - getFragment(...args: Partial): EventFragment; -} - -type __TypechainAOutputTuple = T extends TypedContractEvent< - infer _U, - infer W -> - ? W - : never; -type __TypechainOutputObject = T extends TypedContractEvent< - infer _U, - infer _W, - infer V -> - ? V - : never; - -export interface TypedEventLog - extends Omit { - args: __TypechainAOutputTuple & __TypechainOutputObject; -} - -export interface TypedLogDescription - extends Omit { - args: __TypechainAOutputTuple & __TypechainOutputObject; -} - -export type TypedListener = ( - ...listenerArg: [ - ...__TypechainAOutputTuple, - TypedEventLog, - ...undefined[] - ] -) => void; - -export type MinEthersFactory = { - deploy(...a: ARGS[]): Promise; -}; - -export type GetContractTypeFromFactory = F extends MinEthersFactory< - infer C, - any -> - ? C - : never; -export type GetARGsTypeFromFactory = F extends MinEthersFactory - ? Parameters - : never; - -export type StateMutability = "nonpayable" | "payable" | "view"; - -export type BaseOverrides = Omit; -export type NonPayableOverrides = Omit< - BaseOverrides, - "value" | "blockTag" | "enableCcipRead" ->; -export type PayableOverrides = Omit< - BaseOverrides, - "blockTag" | "enableCcipRead" ->; -export type ViewOverrides = Omit; -export type Overrides = S extends "nonpayable" - ? NonPayableOverrides - : S extends "payable" - ? PayableOverrides - : ViewOverrides; - -export type PostfixOverrides, S extends StateMutability> = - | A - | [...A, Overrides]; -export type ContractMethodArgs< - A extends Array, - S extends StateMutability -> = PostfixOverrides<{ [I in keyof A]-?: A[I] | Typed }, S>; - -export type DefaultReturnType = R extends Array ? R[0] : R; - -// export interface ContractMethod = Array, R = any, D extends R | ContractTransactionResponse = R | ContractTransactionResponse> { -export interface TypedContractMethod< - A extends Array = Array, - R = any, - S extends StateMutability = "payable" -> { - (...args: ContractMethodArgs): S extends "view" - ? Promise> - : Promise; - - name: string; - - fragment: FunctionFragment; - - getFragment(...args: ContractMethodArgs): FunctionFragment; - - populateTransaction( - ...args: ContractMethodArgs - ): Promise; - staticCall( - ...args: ContractMethodArgs - ): Promise>; - send(...args: ContractMethodArgs): Promise; - estimateGas(...args: ContractMethodArgs): Promise; - staticCallResult(...args: ContractMethodArgs): Promise; -} diff --git a/sdk/core/app/contracts/factories/IdentityVerificationHubImpl__factory.ts b/sdk/core/app/contracts/factories/IdentityVerificationHubImpl__factory.ts deleted file mode 100644 index 72fb2f01a..000000000 --- a/sdk/core/app/contracts/factories/IdentityVerificationHubImpl__factory.ts +++ /dev/null @@ -1,836 +0,0 @@ -/* Autogenerated file. Do not edit manually. */ -/* tslint:disable */ -/* eslint-disable */ - -import { Contract, Interface, type ContractRunner } from "ethers"; -import type { - IdentityVerificationHubImpl, - IdentityVerificationHubImplInterface, -} from "../IdentityVerificationHubImpl"; - -const _abi = [ - { - inputs: [], - stateMutability: "nonpayable", - type: "constructor", - }, - { - inputs: [ - { - internalType: "address", - name: "target", - type: "address", - }, - ], - name: "AddressEmptyCode", - type: "error", - }, - { - inputs: [], - name: "CURRENT_DATE_NOT_IN_VALID_RANGE", - type: "error", - }, - { - inputs: [ - { - internalType: "address", - name: "implementation", - type: "address", - }, - ], - name: "ERC1967InvalidImplementation", - type: "error", - }, - { - inputs: [], - name: "ERC1967NonPayable", - type: "error", - }, - { - inputs: [], - name: "FailedCall", - type: "error", - }, - { - inputs: [], - name: "INVALID_ATTESTATION_ID", - type: "error", - }, - { - inputs: [], - name: "INVALID_COMMITMENT_ROOT", - type: "error", - }, - { - inputs: [], - name: "INVALID_CSCA_ROOT", - type: "error", - }, - { - inputs: [], - name: "INVALID_DSC_PROOF", - type: "error", - }, - { - inputs: [], - name: "INVALID_FORBIDDEN_COUNTRIES", - type: "error", - }, - { - inputs: [], - name: "INVALID_OFAC", - type: "error", - }, - { - inputs: [], - name: "INVALID_OFAC_ROOT", - type: "error", - }, - { - inputs: [], - name: "INVALID_OLDER_THAN", - type: "error", - }, - { - inputs: [], - name: "INVALID_REGISTER_PROOF", - type: "error", - }, - { - inputs: [], - name: "INVALID_REVEALED_DATA_TYPE", - type: "error", - }, - { - inputs: [], - name: "INVALID_VC_AND_DISCLOSE_PROOF", - type: "error", - }, - { - inputs: [], - name: "InvalidDateDigit", - type: "error", - }, - { - inputs: [], - name: "InvalidDateLength", - type: "error", - }, - { - inputs: [], - name: "InvalidDayRange", - type: "error", - }, - { - inputs: [], - name: "InvalidFieldElement", - type: "error", - }, - { - inputs: [], - name: "InvalidInitialization", - type: "error", - }, - { - inputs: [], - name: "InvalidMonthRange", - type: "error", - }, - { - inputs: [], - name: "InvalidYearRange", - type: "error", - }, - { - inputs: [], - name: "LENGTH_MISMATCH", - type: "error", - }, - { - inputs: [], - name: "NO_VERIFIER_SET", - type: "error", - }, - { - inputs: [], - name: "NotInitializing", - type: "error", - }, - { - inputs: [ - { - internalType: "address", - name: "owner", - type: "address", - }, - ], - name: "OwnableInvalidOwner", - type: "error", - }, - { - inputs: [ - { - internalType: "address", - name: "account", - type: "address", - }, - ], - name: "OwnableUnauthorizedAccount", - type: "error", - }, - { - inputs: [], - name: "UUPSUnauthorizedCallContext", - type: "error", - }, - { - inputs: [ - { - internalType: "bytes32", - name: "slot", - type: "bytes32", - }, - ], - name: "UUPSUnsupportedProxiableUUID", - type: "error", - }, - { - anonymous: false, - inputs: [ - { - indexed: false, - internalType: "uint256", - name: "typeId", - type: "uint256", - }, - { - indexed: false, - internalType: "address", - name: "verifier", - type: "address", - }, - ], - name: "DscCircuitVerifierUpdated", - type: "event", - }, - { - anonymous: false, - inputs: [ - { - indexed: false, - internalType: "bytes32[]", - name: "attestationIds", - type: "bytes32[]", - }, - { - indexed: false, - internalType: "address[]", - name: "registryAddresses", - type: "address[]", - }, - { - indexed: false, - internalType: "address[]", - name: "vcAndDiscloseCircuitVerifiers", - type: "address[]", - }, - { - indexed: false, - internalType: "uint256[]", - name: "registerCircuitVerifierIds", - type: "uint256[]", - }, - { - indexed: false, - internalType: "address[]", - name: "registerCircuitVerifiers", - type: "address[]", - }, - { - indexed: false, - internalType: "uint256[]", - name: "dscCircuitVerifierIds", - type: "uint256[]", - }, - { - indexed: false, - internalType: "address[]", - name: "dscCircuitVerifiers", - type: "address[]", - }, - ], - name: "HubInitialized", - type: "event", - }, - { - anonymous: false, - inputs: [ - { - indexed: false, - internalType: "uint64", - name: "version", - type: "uint64", - }, - ], - name: "Initialized", - type: "event", - }, - { - anonymous: false, - inputs: [ - { - indexed: true, - internalType: "address", - name: "previousOwner", - type: "address", - }, - { - indexed: true, - internalType: "address", - name: "newOwner", - type: "address", - }, - ], - name: "OwnershipTransferStarted", - type: "event", - }, - { - anonymous: false, - inputs: [ - { - indexed: true, - internalType: "address", - name: "previousOwner", - type: "address", - }, - { - indexed: true, - internalType: "address", - name: "newOwner", - type: "address", - }, - ], - name: "OwnershipTransferred", - type: "event", - }, - { - anonymous: false, - inputs: [ - { - indexed: false, - internalType: "uint256", - name: "typeId", - type: "uint256", - }, - { - indexed: false, - internalType: "address", - name: "verifier", - type: "address", - }, - ], - name: "RegisterCircuitVerifierUpdated", - type: "event", - }, - { - anonymous: false, - inputs: [ - { - indexed: false, - internalType: "bytes32", - name: "attestationId", - type: "bytes32", - }, - { - indexed: false, - internalType: "address", - name: "registry", - type: "address", - }, - ], - name: "RegistryUpdated", - type: "event", - }, - { - anonymous: false, - inputs: [ - { - indexed: true, - internalType: "address", - name: "implementation", - type: "address", - }, - ], - name: "Upgraded", - type: "event", - }, - { - anonymous: false, - inputs: [ - { - indexed: false, - internalType: "bytes32", - name: "attestationId", - type: "bytes32", - }, - { - indexed: false, - internalType: "address", - name: "vcAndDiscloseCircuitVerifier", - type: "address", - }, - ], - name: "VcAndDiscloseCircuitUpdated", - type: "event", - }, - { - inputs: [], - name: "UPGRADE_INTERFACE_VERSION", - outputs: [ - { - internalType: "string", - name: "", - type: "string", - }, - ], - stateMutability: "view", - type: "function", - }, - { - inputs: [], - name: "acceptOwnership", - outputs: [], - stateMutability: "nonpayable", - type: "function", - }, - { - inputs: [ - { - internalType: "uint256[]", - name: "typeIds", - type: "uint256[]", - }, - { - internalType: "address[]", - name: "verifierAddresses", - type: "address[]", - }, - ], - name: "batchUpdateDscCircuitVerifiers", - outputs: [], - stateMutability: "nonpayable", - type: "function", - }, - { - inputs: [ - { - internalType: "uint256[]", - name: "typeIds", - type: "uint256[]", - }, - { - internalType: "address[]", - name: "verifierAddresses", - type: "address[]", - }, - ], - name: "batchUpdateRegisterCircuitVerifiers", - outputs: [], - stateMutability: "nonpayable", - type: "function", - }, - { - inputs: [ - { - internalType: "bytes32[]", - name: "attestationIds", - type: "bytes32[]", - }, - { - internalType: "address[]", - name: "registryAddresses", - type: "address[]", - }, - { - internalType: "address[]", - name: "vcAndDiscloseCircuitVerifierAddresses", - type: "address[]", - }, - { - internalType: "uint256[]", - name: "registerCircuitVerifierIds", - type: "uint256[]", - }, - { - internalType: "address[]", - name: "registerCircuitVerifierAddresses", - type: "address[]", - }, - { - internalType: "uint256[]", - name: "dscCircuitVerifierIds", - type: "uint256[]", - }, - { - internalType: "address[]", - name: "dscCircuitVerifierAddresses", - type: "address[]", - }, - ], - name: "initialize", - outputs: [], - stateMutability: "nonpayable", - type: "function", - }, - { - inputs: [], - name: "owner", - outputs: [ - { - internalType: "address", - name: "", - type: "address", - }, - ], - stateMutability: "view", - type: "function", - }, - { - inputs: [], - name: "pendingOwner", - outputs: [ - { - internalType: "address", - name: "", - type: "address", - }, - ], - stateMutability: "view", - type: "function", - }, - { - inputs: [], - name: "proxiableUUID", - outputs: [ - { - internalType: "bytes32", - name: "", - type: "bytes32", - }, - ], - stateMutability: "view", - type: "function", - }, - { - inputs: [ - { - internalType: "bytes32", - name: "attestationId", - type: "bytes32", - }, - { - internalType: "uint256", - name: "registerCircuitVerifierId", - type: "uint256", - }, - { - components: [ - { - internalType: "uint256[2]", - name: "a", - type: "uint256[2]", - }, - { - internalType: "uint256[2][2]", - name: "b", - type: "uint256[2][2]", - }, - { - internalType: "uint256[2]", - name: "c", - type: "uint256[2]", - }, - { - internalType: "uint256[3]", - name: "pubSignals", - type: "uint256[3]", - }, - ], - internalType: "struct IRegisterCircuitVerifier.RegisterCircuitProof", - name: "registerCircuitProof", - type: "tuple", - }, - ], - name: "registerCommitment", - outputs: [], - stateMutability: "nonpayable", - type: "function", - }, - { - inputs: [ - { - internalType: "bytes32", - name: "attestationId", - type: "bytes32", - }, - { - internalType: "uint256", - name: "dscCircuitVerifierId", - type: "uint256", - }, - { - components: [ - { - internalType: "uint256[2]", - name: "a", - type: "uint256[2]", - }, - { - internalType: "uint256[2][2]", - name: "b", - type: "uint256[2][2]", - }, - { - internalType: "uint256[2]", - name: "c", - type: "uint256[2]", - }, - { - internalType: "uint256[2]", - name: "pubSignals", - type: "uint256[2]", - }, - ], - internalType: "struct IDscCircuitVerifier.DscCircuitProof", - name: "dscCircuitProof", - type: "tuple", - }, - ], - name: "registerDscKeyCommitment", - outputs: [], - stateMutability: "nonpayable", - type: "function", - }, - { - inputs: [ - { - internalType: "bytes32", - name: "attestationId", - type: "bytes32", - }, - ], - name: "registry", - outputs: [ - { - internalType: "address", - name: "", - type: "address", - }, - ], - stateMutability: "view", - type: "function", - }, - { - inputs: [], - name: "renounceOwnership", - outputs: [], - stateMutability: "nonpayable", - type: "function", - }, - { - inputs: [ - { - internalType: "uint256", - name: "typeId", - type: "uint256", - }, - ], - name: "sigTypeToDscCircuitVerifiers", - outputs: [ - { - internalType: "address", - name: "", - type: "address", - }, - ], - stateMutability: "view", - type: "function", - }, - { - inputs: [ - { - internalType: "uint256", - name: "typeId", - type: "uint256", - }, - ], - name: "sigTypeToRegisterCircuitVerifiers", - outputs: [ - { - internalType: "address", - name: "", - type: "address", - }, - ], - stateMutability: "view", - type: "function", - }, - { - inputs: [ - { - internalType: "address", - name: "newOwner", - type: "address", - }, - ], - name: "transferOwnership", - outputs: [], - stateMutability: "nonpayable", - type: "function", - }, - { - inputs: [ - { - internalType: "uint256", - name: "typeId", - type: "uint256", - }, - { - internalType: "address", - name: "verifierAddress", - type: "address", - }, - ], - name: "updateDscVerifier", - outputs: [], - stateMutability: "nonpayable", - type: "function", - }, - { - inputs: [ - { - internalType: "uint256", - name: "typeId", - type: "uint256", - }, - { - internalType: "address", - name: "verifierAddress", - type: "address", - }, - ], - name: "updateRegisterCircuitVerifier", - outputs: [], - stateMutability: "nonpayable", - type: "function", - }, - { - inputs: [ - { - internalType: "bytes32", - name: "attestationId", - type: "bytes32", - }, - { - internalType: "address", - name: "registryAddress", - type: "address", - }, - ], - name: "updateRegistry", - outputs: [], - stateMutability: "nonpayable", - type: "function", - }, - { - inputs: [ - { - internalType: "bytes32", - name: "attestationId", - type: "bytes32", - }, - { - internalType: "address", - name: "vcAndDiscloseCircuitVerifierAddress", - type: "address", - }, - ], - name: "updateVcAndDiscloseCircuit", - outputs: [], - stateMutability: "nonpayable", - type: "function", - }, - { - inputs: [ - { - internalType: "address", - name: "newImplementation", - type: "address", - }, - { - internalType: "bytes", - name: "data", - type: "bytes", - }, - ], - name: "upgradeToAndCall", - outputs: [], - stateMutability: "payable", - type: "function", - }, - { - inputs: [ - { - internalType: "bytes32", - name: "attestationId", - type: "bytes32", - }, - ], - name: "vcAndDiscloseCircuitVerifier", - outputs: [ - { - internalType: "address", - name: "", - type: "address", - }, - ], - stateMutability: "view", - type: "function", - }, - { - inputs: [ - { - internalType: "bytes", - name: "proofData", - type: "bytes", - }, - ], - name: "verifyVcAndDisclose", - outputs: [ - { - internalType: "bytes", - name: "result", - type: "bytes", - }, - ], - stateMutability: "view", - type: "function", - }, -] as const; - -export class IdentityVerificationHubImpl__factory { - static readonly abi = _abi; - static createInterface(): IdentityVerificationHubImplInterface { - return new Interface(_abi) as IdentityVerificationHubImplInterface; - } - static connect( - address: string, - runner?: ContractRunner | null - ): IdentityVerificationHubImpl { - return new Contract( - address, - _abi, - runner - ) as unknown as IdentityVerificationHubImpl; - } -} diff --git a/sdk/core/app/contracts/factories/index.ts b/sdk/core/app/contracts/factories/index.ts deleted file mode 100644 index 1a0b7aee7..000000000 --- a/sdk/core/app/contracts/factories/index.ts +++ /dev/null @@ -1,4 +0,0 @@ -/* Autogenerated file. Do not edit manually. */ -/* tslint:disable */ -/* eslint-disable */ -export { IdentityVerificationHubImpl__factory } from "./IdentityVerificationHubImpl__factory"; diff --git a/sdk/core/app/contracts/index.ts b/sdk/core/app/contracts/index.ts deleted file mode 100644 index a7318c94b..000000000 --- a/sdk/core/app/contracts/index.ts +++ /dev/null @@ -1,6 +0,0 @@ -/* Autogenerated file. Do not edit manually. */ -/* tslint:disable */ -/* eslint-disable */ -export type { IdentityVerificationHubImpl } from "./IdentityVerificationHubImpl"; -export * as factories from "./factories"; -export { IdentityVerificationHubImpl__factory } from "./factories/IdentityVerificationHubImpl__factory"; diff --git a/sdk/core/package.json b/sdk/core/package.json index 199028ddb..b9d5c7158 100644 --- a/sdk/core/package.json +++ b/sdk/core/package.json @@ -27,7 +27,7 @@ "dist" ], "scripts": { - "build": "tsup index.ts --format cjs,esm --dts --clean --sourcemap", + "build": "typechain --target ethers-v6 --node16-modules --out-dir src/typechain-types src/abi/**.json && tsup index.ts --format cjs,esm --dts --clean --sourcemap", "build:deps": "yarn workspaces foreach --from @selfxyz/core --topological-dev --recursive run build", "copy-abi": "bash scripts/copyAbi.sh", "format": "prettier --write .", diff --git a/sdk/core/scripts/fix-imports.js b/sdk/core/scripts/fix-imports.js deleted file mode 100644 index 32702218b..000000000 --- a/sdk/core/scripts/fix-imports.js +++ /dev/null @@ -1,26 +0,0 @@ -import { readdir, readFile, writeFile } from 'fs/promises'; -import { join } from 'path'; - -async function fixImports() { - const typechainDir = join(process.cwd(), 'src', 'typechain-types'); - - // Read all files in the typechain-types directory - const files = await readdir(typechainDir); - - for (const file of files) { - if (file.endsWith('.ts')) { - const filePath = join(typechainDir, file); - const content = await readFile(filePath, 'utf-8'); - - // Add .js extension to all relative imports - const modifiedContent = content.replace( - /from ['"](\.\/[^'"]+)['"]/g, - 'from "$1.js"' - ); - - await writeFile(filePath, modifiedContent); - } - } -} - -fixImports().catch(console.error); diff --git a/sdk/core/src/abi/IdentityVerificationHubImpl.json b/sdk/core/src/abi/IdentityVerificationHubImpl.json index de2013196..398e6fba1 100644 --- a/sdk/core/src/abi/IdentityVerificationHubImpl.json +++ b/sdk/core/src/abi/IdentityVerificationHubImpl.json @@ -3,454 +3,6 @@ "contractName": "IdentityVerificationHubImplV2", "sourceName": "contracts/IdentityVerificationHubImplV2.sol", "abi": [ - { - "inputs": [], - "stateMutability": "nonpayable", - "type": "constructor" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "target", - "type": "address" - } - ], - "name": "AddressEmptyCode", - "type": "error" - }, - { - "inputs": [], - "name": "CrossChainIsNotSupportedYet", - "type": "error" - }, - { - "inputs": [], - "name": "CurrentDateNotInValidRange", - "type": "error" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "implementation", - "type": "address" - } - ], - "name": "ERC1967InvalidImplementation", - "type": "error" - }, - { - "inputs": [], - "name": "ERC1967NonPayable", - "type": "error" - }, - { - "inputs": [], - "name": "FailedCall", - "type": "error" - }, - { - "inputs": [], - "name": "InputTooShort", - "type": "error" - }, - { - "inputs": [], - "name": "InvalidAttestationId", - "type": "error" - }, - { - "inputs": [], - "name": "InvalidCscaRoot", - "type": "error" - }, - { - "inputs": [], - "name": "InvalidDateDigit", - "type": "error" - }, - { - "inputs": [], - "name": "InvalidDateLength", - "type": "error" - }, - { - "inputs": [], - "name": "InvalidDayRange", - "type": "error" - }, - { - "inputs": [], - "name": "InvalidDscCommitmentRoot", - "type": "error" - }, - { - "inputs": [], - "name": "InvalidDscProof", - "type": "error" - }, - { - "inputs": [], - "name": "InvalidFieldElement", - "type": "error" - }, - { - "inputs": [], - "name": "InvalidIdentityCommitmentRoot", - "type": "error" - }, - { - "inputs": [], - "name": "InvalidInitialization", - "type": "error" - }, - { - "inputs": [], - "name": "InvalidMonthRange", - "type": "error" - }, - { - "inputs": [], - "name": "InvalidRegisterProof", - "type": "error" - }, - { - "inputs": [], - "name": "InvalidUserIdentifierInProof", - "type": "error" - }, - { - "inputs": [], - "name": "InvalidVcAndDiscloseProof", - "type": "error" - }, - { - "inputs": [], - "name": "InvalidYearRange", - "type": "error" - }, - { - "inputs": [], - "name": "LengthMismatch", - "type": "error" - }, - { - "inputs": [], - "name": "NoVerifierSet", - "type": "error" - }, - { - "inputs": [], - "name": "NotInitializing", - "type": "error" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "owner", - "type": "address" - } - ], - "name": "OwnableInvalidOwner", - "type": "error" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "account", - "type": "address" - } - ], - "name": "OwnableUnauthorizedAccount", - "type": "error" - }, - { - "inputs": [], - "name": "ScopeMismatch", - "type": "error" - }, - { - "inputs": [], - "name": "UUPSUnauthorizedCallContext", - "type": "error" - }, - { - "inputs": [ - { - "internalType": "bytes32", - "name": "slot", - "type": "bytes32" - } - ], - "name": "UUPSUnsupportedProxiableUUID", - "type": "error" - }, - { - "inputs": [], - "name": "UserContextDataTooShort", - "type": "error" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": false, - "internalType": "uint256", - "name": "typeId", - "type": "uint256" - }, - { - "indexed": false, - "internalType": "address", - "name": "verifier", - "type": "address" - } - ], - "name": "DscCircuitVerifierUpdated", - "type": "event" - }, - { - "anonymous": false, - "inputs": [], - "name": "HubInitializedV2", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": false, - "internalType": "uint64", - "name": "version", - "type": "uint64" - } - ], - "name": "Initialized", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "address", - "name": "previousOwner", - "type": "address" - }, - { - "indexed": true, - "internalType": "address", - "name": "newOwner", - "type": "address" - } - ], - "name": "OwnershipTransferStarted", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "address", - "name": "previousOwner", - "type": "address" - }, - { - "indexed": true, - "internalType": "address", - "name": "newOwner", - "type": "address" - } - ], - "name": "OwnershipTransferred", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": false, - "internalType": "uint256", - "name": "typeId", - "type": "uint256" - }, - { - "indexed": false, - "internalType": "address", - "name": "verifier", - "type": "address" - } - ], - "name": "RegisterCircuitVerifierUpdated", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": false, - "internalType": "bytes32", - "name": "attestationId", - "type": "bytes32" - }, - { - "indexed": false, - "internalType": "address", - "name": "registry", - "type": "address" - } - ], - "name": "RegistryUpdated", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "address", - "name": "implementation", - "type": "address" - } - ], - "name": "Upgraded", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": false, - "internalType": "bytes32", - "name": "attestationId", - "type": "bytes32" - }, - { - "indexed": false, - "internalType": "address", - "name": "vcAndDiscloseCircuitVerifier", - "type": "address" - } - ], - "name": "VcAndDiscloseCircuitUpdated", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "bytes32", - "name": "configId", - "type": "bytes32" - }, - { - "components": [ - { - "internalType": "bool", - "name": "olderThanEnabled", - "type": "bool" - }, - { - "internalType": "uint256", - "name": "olderThan", - "type": "uint256" - }, - { - "internalType": "bool", - "name": "forbiddenCountriesEnabled", - "type": "bool" - }, - { - "internalType": "uint256[4]", - "name": "forbiddenCountriesListPacked", - "type": "uint256[4]" - }, - { - "internalType": "bool[3]", - "name": "ofacEnabled", - "type": "bool[3]" - } - ], - "indexed": false, - "internalType": "struct SelfStructs.VerificationConfigV2", - "name": "config", - "type": "tuple" - } - ], - "name": "VerificationConfigV2Set", - "type": "event" - }, - { - "inputs": [], - "name": "UPGRADE_INTERFACE_VERSION", - "outputs": [ - { - "internalType": "string", - "name": "", - "type": "string" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "acceptOwnership", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "bytes32[]", - "name": "attestationIds", - "type": "bytes32[]" - }, - { - "internalType": "uint256[]", - "name": "typeIds", - "type": "uint256[]" - }, - { - "internalType": "address[]", - "name": "verifierAddresses", - "type": "address[]" - } - ], - "name": "batchUpdateDscCircuitVerifiers", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "bytes32[]", - "name": "attestationIds", - "type": "bytes32[]" - }, - { - "internalType": "uint256[]", - "name": "typeIds", - "type": "uint256[]" - }, - { - "internalType": "address[]", - "name": "verifierAddresses", - "type": "address[]" - } - ], - "name": "batchUpdateRegisterCircuitVerifiers", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, { "inputs": [ { @@ -470,255 +22,6 @@ "stateMutability": "view", "type": "function" }, - { - "inputs": [ - { - "internalType": "bytes32", - "name": "attestationId", - "type": "bytes32" - }, - { - "internalType": "uint256", - "name": "typeId", - "type": "uint256" - } - ], - "name": "dscCircuitVerifiers", - "outputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "components": [ - { - "internalType": "bool", - "name": "olderThanEnabled", - "type": "bool" - }, - { - "internalType": "uint256", - "name": "olderThan", - "type": "uint256" - }, - { - "internalType": "bool", - "name": "forbiddenCountriesEnabled", - "type": "bool" - }, - { - "internalType": "uint256[4]", - "name": "forbiddenCountriesListPacked", - "type": "uint256[4]" - }, - { - "internalType": "bool[3]", - "name": "ofacEnabled", - "type": "bool[3]" - } - ], - "internalType": "struct SelfStructs.VerificationConfigV2", - "name": "config", - "type": "tuple" - } - ], - "name": "generateConfigId", - "outputs": [ - { - "internalType": "bytes32", - "name": "", - "type": "bytes32" - } - ], - "stateMutability": "pure", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "bytes32", - "name": "attestationId", - "type": "bytes32" - } - ], - "name": "getIdentityCommitmentMerkleRoot", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "initialize", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [], - "name": "owner", - "outputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "pendingOwner", - "outputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "proxiableUUID", - "outputs": [ - { - "internalType": "bytes32", - "name": "", - "type": "bytes32" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "bytes32", - "name": "attestationId", - "type": "bytes32" - }, - { - "internalType": "uint256", - "name": "typeId", - "type": "uint256" - } - ], - "name": "registerCircuitVerifiers", - "outputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "bytes32", - "name": "attestationId", - "type": "bytes32" - }, - { - "internalType": "uint256", - "name": "registerCircuitVerifierId", - "type": "uint256" - }, - { - "components": [ - { - "internalType": "uint256[2]", - "name": "a", - "type": "uint256[2]" - }, - { - "internalType": "uint256[2][2]", - "name": "b", - "type": "uint256[2][2]" - }, - { - "internalType": "uint256[2]", - "name": "c", - "type": "uint256[2]" - }, - { - "internalType": "uint256[3]", - "name": "pubSignals", - "type": "uint256[3]" - } - ], - "internalType": "struct IRegisterCircuitVerifier.RegisterCircuitProof", - "name": "registerCircuitProof", - "type": "tuple" - } - ], - "name": "registerCommitment", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "bytes32", - "name": "attestationId", - "type": "bytes32" - }, - { - "internalType": "uint256", - "name": "dscCircuitVerifierId", - "type": "uint256" - }, - { - "components": [ - { - "internalType": "uint256[2]", - "name": "a", - "type": "uint256[2]" - }, - { - "internalType": "uint256[2][2]", - "name": "b", - "type": "uint256[2][2]" - }, - { - "internalType": "uint256[2]", - "name": "c", - "type": "uint256[2]" - }, - { - "internalType": "uint256[2]", - "name": "pubSignals", - "type": "uint256[2]" - } - ], - "internalType": "struct IDscCircuitVerifier.DscCircuitProof", - "name": "dscCircuitProof", - "type": "tuple" - } - ], - "name": "registerDscKeyCommitment", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, { "inputs": [ { @@ -737,233 +40,6 @@ ], "stateMutability": "view", "type": "function" - }, - { - "inputs": [], - "name": "renounceOwnership", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "bytes32", - "name": "attestationId", - "type": "bytes32" - }, - { - "internalType": "uint256", - "name": "root", - "type": "uint256" - } - ], - "name": "rootTimestamp", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "components": [ - { - "internalType": "bool", - "name": "olderThanEnabled", - "type": "bool" - }, - { - "internalType": "uint256", - "name": "olderThan", - "type": "uint256" - }, - { - "internalType": "bool", - "name": "forbiddenCountriesEnabled", - "type": "bool" - }, - { - "internalType": "uint256[4]", - "name": "forbiddenCountriesListPacked", - "type": "uint256[4]" - }, - { - "internalType": "bool[3]", - "name": "ofacEnabled", - "type": "bool[3]" - } - ], - "internalType": "struct SelfStructs.VerificationConfigV2", - "name": "config", - "type": "tuple" - } - ], - "name": "setVerificationConfigV2", - "outputs": [ - { - "internalType": "bytes32", - "name": "configId", - "type": "bytes32" - } - ], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "newOwner", - "type": "address" - } - ], - "name": "transferOwnership", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "bytes32", - "name": "attestationId", - "type": "bytes32" - }, - { - "internalType": "uint256", - "name": "typeId", - "type": "uint256" - }, - { - "internalType": "address", - "name": "verifierAddress", - "type": "address" - } - ], - "name": "updateDscVerifier", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "bytes32", - "name": "attestationId", - "type": "bytes32" - }, - { - "internalType": "uint256", - "name": "typeId", - "type": "uint256" - }, - { - "internalType": "address", - "name": "verifierAddress", - "type": "address" - } - ], - "name": "updateRegisterCircuitVerifier", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "bytes32", - "name": "attestationId", - "type": "bytes32" - }, - { - "internalType": "address", - "name": "registryAddress", - "type": "address" - } - ], - "name": "updateRegistry", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "bytes32", - "name": "attestationId", - "type": "bytes32" - }, - { - "internalType": "address", - "name": "vcAndDiscloseCircuitVerifierAddress", - "type": "address" - } - ], - "name": "updateVcAndDiscloseCircuit", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "newImplementation", - "type": "address" - }, - { - "internalType": "bytes", - "name": "data", - "type": "bytes" - } - ], - "name": "upgradeToAndCall", - "outputs": [], - "stateMutability": "payable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "bytes32", - "name": "configId", - "type": "bytes32" - } - ], - "name": "verificationConfigV2Exists", - "outputs": [ - { - "internalType": "bool", - "name": "exists", - "type": "bool" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "bytes", - "name": "baseVerificationInput", - "type": "bytes" - }, - { - "internalType": "bytes", - "name": "userContextData", - "type": "bytes" - } - ], - "name": "verify", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" } ] } diff --git a/sdk/core/src/typechain-types/IdentityVerificationHubImpl.ts b/sdk/core/src/typechain-types/IdentityVerificationHubImpl.ts deleted file mode 100644 index 581968f2f..000000000 --- a/sdk/core/src/typechain-types/IdentityVerificationHubImpl.ts +++ /dev/null @@ -1,1040 +0,0 @@ -/* Autogenerated file. Do not edit manually. */ -/* tslint:disable */ -/* eslint-disable */ -import type { - BaseContract, - BigNumberish, - BytesLike, - FunctionFragment, - Result, - Interface, - EventFragment, - AddressLike, - ContractRunner, - ContractMethod, - Listener, -} from "ethers"; -import type { - TypedContractEvent, - TypedDeferredTopicFilter, - TypedEventLog, - TypedLogDescription, - TypedListener, - TypedContractMethod, -} from "./common.js"; - -export declare namespace SelfStructs { - export type VerificationConfigV2Struct = { - olderThanEnabled: boolean; - olderThan: BigNumberish; - forbiddenCountriesEnabled: boolean; - forbiddenCountriesListPacked: [ - BigNumberish, - BigNumberish, - BigNumberish, - BigNumberish - ]; - ofacEnabled: [boolean, boolean, boolean]; - }; - - export type VerificationConfigV2StructOutput = [ - olderThanEnabled: boolean, - olderThan: bigint, - forbiddenCountriesEnabled: boolean, - forbiddenCountriesListPacked: [bigint, bigint, bigint, bigint], - ofacEnabled: [boolean, boolean, boolean] - ] & { - olderThanEnabled: boolean; - olderThan: bigint; - forbiddenCountriesEnabled: boolean; - forbiddenCountriesListPacked: [bigint, bigint, bigint, bigint]; - ofacEnabled: [boolean, boolean, boolean]; - }; -} - -export declare namespace IRegisterCircuitVerifier { - export type RegisterCircuitProofStruct = { - a: [BigNumberish, BigNumberish]; - b: [[BigNumberish, BigNumberish], [BigNumberish, BigNumberish]]; - c: [BigNumberish, BigNumberish]; - pubSignals: [BigNumberish, BigNumberish, BigNumberish]; - }; - - export type RegisterCircuitProofStructOutput = [ - a: [bigint, bigint], - b: [[bigint, bigint], [bigint, bigint]], - c: [bigint, bigint], - pubSignals: [bigint, bigint, bigint] - ] & { - a: [bigint, bigint]; - b: [[bigint, bigint], [bigint, bigint]]; - c: [bigint, bigint]; - pubSignals: [bigint, bigint, bigint]; - }; -} - -export declare namespace IDscCircuitVerifier { - export type DscCircuitProofStruct = { - a: [BigNumberish, BigNumberish]; - b: [[BigNumberish, BigNumberish], [BigNumberish, BigNumberish]]; - c: [BigNumberish, BigNumberish]; - pubSignals: [BigNumberish, BigNumberish]; - }; - - export type DscCircuitProofStructOutput = [ - a: [bigint, bigint], - b: [[bigint, bigint], [bigint, bigint]], - c: [bigint, bigint], - pubSignals: [bigint, bigint] - ] & { - a: [bigint, bigint]; - b: [[bigint, bigint], [bigint, bigint]]; - c: [bigint, bigint]; - pubSignals: [bigint, bigint]; - }; -} - -export interface IdentityVerificationHubImplInterface extends Interface { - getFunction( - nameOrSignature: - | "UPGRADE_INTERFACE_VERSION" - | "acceptOwnership" - | "batchUpdateDscCircuitVerifiers" - | "batchUpdateRegisterCircuitVerifiers" - | "discloseVerifier" - | "dscCircuitVerifiers" - | "generateConfigId" - | "getIdentityCommitmentMerkleRoot" - | "initialize" - | "owner" - | "pendingOwner" - | "proxiableUUID" - | "registerCircuitVerifiers" - | "registerCommitment" - | "registerDscKeyCommitment" - | "registry" - | "renounceOwnership" - | "rootTimestamp" - | "setVerificationConfigV2" - | "transferOwnership" - | "updateDscVerifier" - | "updateRegisterCircuitVerifier" - | "updateRegistry" - | "updateVcAndDiscloseCircuit" - | "upgradeToAndCall" - | "verificationConfigV2Exists" - | "verify" - ): FunctionFragment; - - getEvent( - nameOrSignatureOrTopic: - | "DscCircuitVerifierUpdated" - | "HubInitializedV2" - | "Initialized" - | "OwnershipTransferStarted" - | "OwnershipTransferred" - | "RegisterCircuitVerifierUpdated" - | "RegistryUpdated" - | "Upgraded" - | "VcAndDiscloseCircuitUpdated" - | "VerificationConfigV2Set" - ): EventFragment; - - encodeFunctionData( - functionFragment: "UPGRADE_INTERFACE_VERSION", - values?: undefined - ): string; - encodeFunctionData( - functionFragment: "acceptOwnership", - values?: undefined - ): string; - encodeFunctionData( - functionFragment: "batchUpdateDscCircuitVerifiers", - values: [BytesLike[], BigNumberish[], AddressLike[]] - ): string; - encodeFunctionData( - functionFragment: "batchUpdateRegisterCircuitVerifiers", - values: [BytesLike[], BigNumberish[], AddressLike[]] - ): string; - encodeFunctionData( - functionFragment: "discloseVerifier", - values: [BytesLike] - ): string; - encodeFunctionData( - functionFragment: "dscCircuitVerifiers", - values: [BytesLike, BigNumberish] - ): string; - encodeFunctionData( - functionFragment: "generateConfigId", - values: [SelfStructs.VerificationConfigV2Struct] - ): string; - encodeFunctionData( - functionFragment: "getIdentityCommitmentMerkleRoot", - values: [BytesLike] - ): string; - encodeFunctionData( - functionFragment: "initialize", - values?: undefined - ): string; - encodeFunctionData(functionFragment: "owner", values?: undefined): string; - encodeFunctionData( - functionFragment: "pendingOwner", - values?: undefined - ): string; - encodeFunctionData( - functionFragment: "proxiableUUID", - values?: undefined - ): string; - encodeFunctionData( - functionFragment: "registerCircuitVerifiers", - values: [BytesLike, BigNumberish] - ): string; - encodeFunctionData( - functionFragment: "registerCommitment", - values: [ - BytesLike, - BigNumberish, - IRegisterCircuitVerifier.RegisterCircuitProofStruct - ] - ): string; - encodeFunctionData( - functionFragment: "registerDscKeyCommitment", - values: [BytesLike, BigNumberish, IDscCircuitVerifier.DscCircuitProofStruct] - ): string; - encodeFunctionData(functionFragment: "registry", values: [BytesLike]): string; - encodeFunctionData( - functionFragment: "renounceOwnership", - values?: undefined - ): string; - encodeFunctionData( - functionFragment: "rootTimestamp", - values: [BytesLike, BigNumberish] - ): string; - encodeFunctionData( - functionFragment: "setVerificationConfigV2", - values: [SelfStructs.VerificationConfigV2Struct] - ): string; - encodeFunctionData( - functionFragment: "transferOwnership", - values: [AddressLike] - ): string; - encodeFunctionData( - functionFragment: "updateDscVerifier", - values: [BytesLike, BigNumberish, AddressLike] - ): string; - encodeFunctionData( - functionFragment: "updateRegisterCircuitVerifier", - values: [BytesLike, BigNumberish, AddressLike] - ): string; - encodeFunctionData( - functionFragment: "updateRegistry", - values: [BytesLike, AddressLike] - ): string; - encodeFunctionData( - functionFragment: "updateVcAndDiscloseCircuit", - values: [BytesLike, AddressLike] - ): string; - encodeFunctionData( - functionFragment: "upgradeToAndCall", - values: [AddressLike, BytesLike] - ): string; - encodeFunctionData( - functionFragment: "verificationConfigV2Exists", - values: [BytesLike] - ): string; - encodeFunctionData( - functionFragment: "verify", - values: [BytesLike, BytesLike] - ): string; - - decodeFunctionResult( - functionFragment: "UPGRADE_INTERFACE_VERSION", - data: BytesLike - ): Result; - decodeFunctionResult( - functionFragment: "acceptOwnership", - data: BytesLike - ): Result; - decodeFunctionResult( - functionFragment: "batchUpdateDscCircuitVerifiers", - data: BytesLike - ): Result; - decodeFunctionResult( - functionFragment: "batchUpdateRegisterCircuitVerifiers", - data: BytesLike - ): Result; - decodeFunctionResult( - functionFragment: "discloseVerifier", - data: BytesLike - ): Result; - decodeFunctionResult( - functionFragment: "dscCircuitVerifiers", - data: BytesLike - ): Result; - decodeFunctionResult( - functionFragment: "generateConfigId", - data: BytesLike - ): Result; - decodeFunctionResult( - functionFragment: "getIdentityCommitmentMerkleRoot", - data: BytesLike - ): Result; - decodeFunctionResult(functionFragment: "initialize", data: BytesLike): Result; - decodeFunctionResult(functionFragment: "owner", data: BytesLike): Result; - decodeFunctionResult( - functionFragment: "pendingOwner", - data: BytesLike - ): Result; - decodeFunctionResult( - functionFragment: "proxiableUUID", - data: BytesLike - ): Result; - decodeFunctionResult( - functionFragment: "registerCircuitVerifiers", - data: BytesLike - ): Result; - decodeFunctionResult( - functionFragment: "registerCommitment", - data: BytesLike - ): Result; - decodeFunctionResult( - functionFragment: "registerDscKeyCommitment", - data: BytesLike - ): Result; - decodeFunctionResult(functionFragment: "registry", data: BytesLike): Result; - decodeFunctionResult( - functionFragment: "renounceOwnership", - data: BytesLike - ): Result; - decodeFunctionResult( - functionFragment: "rootTimestamp", - data: BytesLike - ): Result; - decodeFunctionResult( - functionFragment: "setVerificationConfigV2", - data: BytesLike - ): Result; - decodeFunctionResult( - functionFragment: "transferOwnership", - data: BytesLike - ): Result; - decodeFunctionResult( - functionFragment: "updateDscVerifier", - data: BytesLike - ): Result; - decodeFunctionResult( - functionFragment: "updateRegisterCircuitVerifier", - data: BytesLike - ): Result; - decodeFunctionResult( - functionFragment: "updateRegistry", - data: BytesLike - ): Result; - decodeFunctionResult( - functionFragment: "updateVcAndDiscloseCircuit", - data: BytesLike - ): Result; - decodeFunctionResult( - functionFragment: "upgradeToAndCall", - data: BytesLike - ): Result; - decodeFunctionResult( - functionFragment: "verificationConfigV2Exists", - data: BytesLike - ): Result; - decodeFunctionResult(functionFragment: "verify", data: BytesLike): Result; -} - -export namespace DscCircuitVerifierUpdatedEvent { - export type InputTuple = [typeId: BigNumberish, verifier: AddressLike]; - export type OutputTuple = [typeId: bigint, verifier: string]; - export interface OutputObject { - typeId: bigint; - verifier: string; - } - export type Event = TypedContractEvent; - export type Filter = TypedDeferredTopicFilter; - export type Log = TypedEventLog; - export type LogDescription = TypedLogDescription; -} - -export namespace HubInitializedV2Event { - export type InputTuple = []; - export type OutputTuple = []; - export interface OutputObject {} - export type Event = TypedContractEvent; - export type Filter = TypedDeferredTopicFilter; - export type Log = TypedEventLog; - export type LogDescription = TypedLogDescription; -} - -export namespace InitializedEvent { - export type InputTuple = [version: BigNumberish]; - export type OutputTuple = [version: bigint]; - export interface OutputObject { - version: bigint; - } - export type Event = TypedContractEvent; - export type Filter = TypedDeferredTopicFilter; - export type Log = TypedEventLog; - export type LogDescription = TypedLogDescription; -} - -export namespace OwnershipTransferStartedEvent { - export type InputTuple = [previousOwner: AddressLike, newOwner: AddressLike]; - export type OutputTuple = [previousOwner: string, newOwner: string]; - export interface OutputObject { - previousOwner: string; - newOwner: string; - } - export type Event = TypedContractEvent; - export type Filter = TypedDeferredTopicFilter; - export type Log = TypedEventLog; - export type LogDescription = TypedLogDescription; -} - -export namespace OwnershipTransferredEvent { - export type InputTuple = [previousOwner: AddressLike, newOwner: AddressLike]; - export type OutputTuple = [previousOwner: string, newOwner: string]; - export interface OutputObject { - previousOwner: string; - newOwner: string; - } - export type Event = TypedContractEvent; - export type Filter = TypedDeferredTopicFilter; - export type Log = TypedEventLog; - export type LogDescription = TypedLogDescription; -} - -export namespace RegisterCircuitVerifierUpdatedEvent { - export type InputTuple = [typeId: BigNumberish, verifier: AddressLike]; - export type OutputTuple = [typeId: bigint, verifier: string]; - export interface OutputObject { - typeId: bigint; - verifier: string; - } - export type Event = TypedContractEvent; - export type Filter = TypedDeferredTopicFilter; - export type Log = TypedEventLog; - export type LogDescription = TypedLogDescription; -} - -export namespace RegistryUpdatedEvent { - export type InputTuple = [attestationId: BytesLike, registry: AddressLike]; - export type OutputTuple = [attestationId: string, registry: string]; - export interface OutputObject { - attestationId: string; - registry: string; - } - export type Event = TypedContractEvent; - export type Filter = TypedDeferredTopicFilter; - export type Log = TypedEventLog; - export type LogDescription = TypedLogDescription; -} - -export namespace UpgradedEvent { - export type InputTuple = [implementation: AddressLike]; - export type OutputTuple = [implementation: string]; - export interface OutputObject { - implementation: string; - } - export type Event = TypedContractEvent; - export type Filter = TypedDeferredTopicFilter; - export type Log = TypedEventLog; - export type LogDescription = TypedLogDescription; -} - -export namespace VcAndDiscloseCircuitUpdatedEvent { - export type InputTuple = [ - attestationId: BytesLike, - vcAndDiscloseCircuitVerifier: AddressLike - ]; - export type OutputTuple = [ - attestationId: string, - vcAndDiscloseCircuitVerifier: string - ]; - export interface OutputObject { - attestationId: string; - vcAndDiscloseCircuitVerifier: string; - } - export type Event = TypedContractEvent; - export type Filter = TypedDeferredTopicFilter; - export type Log = TypedEventLog; - export type LogDescription = TypedLogDescription; -} - -export namespace VerificationConfigV2SetEvent { - export type InputTuple = [ - configId: BytesLike, - config: SelfStructs.VerificationConfigV2Struct - ]; - export type OutputTuple = [ - configId: string, - config: SelfStructs.VerificationConfigV2StructOutput - ]; - export interface OutputObject { - configId: string; - config: SelfStructs.VerificationConfigV2StructOutput; - } - export type Event = TypedContractEvent; - export type Filter = TypedDeferredTopicFilter; - export type Log = TypedEventLog; - export type LogDescription = TypedLogDescription; -} - -export interface IdentityVerificationHubImpl extends BaseContract { - connect(runner?: ContractRunner | null): IdentityVerificationHubImpl; - waitForDeployment(): Promise; - - interface: IdentityVerificationHubImplInterface; - - queryFilter( - event: TCEvent, - fromBlockOrBlockhash?: string | number | undefined, - toBlock?: string | number | undefined - ): Promise>>; - queryFilter( - filter: TypedDeferredTopicFilter, - fromBlockOrBlockhash?: string | number | undefined, - toBlock?: string | number | undefined - ): Promise>>; - - on( - event: TCEvent, - listener: TypedListener - ): Promise; - on( - filter: TypedDeferredTopicFilter, - listener: TypedListener - ): Promise; - - once( - event: TCEvent, - listener: TypedListener - ): Promise; - once( - filter: TypedDeferredTopicFilter, - listener: TypedListener - ): Promise; - - listeners( - event: TCEvent - ): Promise>>; - listeners(eventName?: string): Promise>; - removeAllListeners( - event?: TCEvent - ): Promise; - - UPGRADE_INTERFACE_VERSION: TypedContractMethod<[], [string], "view">; - - acceptOwnership: TypedContractMethod<[], [void], "nonpayable">; - - batchUpdateDscCircuitVerifiers: TypedContractMethod< - [ - attestationIds: BytesLike[], - typeIds: BigNumberish[], - verifierAddresses: AddressLike[] - ], - [void], - "nonpayable" - >; - - batchUpdateRegisterCircuitVerifiers: TypedContractMethod< - [ - attestationIds: BytesLike[], - typeIds: BigNumberish[], - verifierAddresses: AddressLike[] - ], - [void], - "nonpayable" - >; - - discloseVerifier: TypedContractMethod< - [attestationId: BytesLike], - [string], - "view" - >; - - dscCircuitVerifiers: TypedContractMethod< - [attestationId: BytesLike, typeId: BigNumberish], - [string], - "view" - >; - - generateConfigId: TypedContractMethod< - [config: SelfStructs.VerificationConfigV2Struct], - [string], - "view" - >; - - getIdentityCommitmentMerkleRoot: TypedContractMethod< - [attestationId: BytesLike], - [bigint], - "view" - >; - - initialize: TypedContractMethod<[], [void], "nonpayable">; - - owner: TypedContractMethod<[], [string], "view">; - - pendingOwner: TypedContractMethod<[], [string], "view">; - - proxiableUUID: TypedContractMethod<[], [string], "view">; - - registerCircuitVerifiers: TypedContractMethod< - [attestationId: BytesLike, typeId: BigNumberish], - [string], - "view" - >; - - registerCommitment: TypedContractMethod< - [ - attestationId: BytesLike, - registerCircuitVerifierId: BigNumberish, - registerCircuitProof: IRegisterCircuitVerifier.RegisterCircuitProofStruct - ], - [void], - "nonpayable" - >; - - registerDscKeyCommitment: TypedContractMethod< - [ - attestationId: BytesLike, - dscCircuitVerifierId: BigNumberish, - dscCircuitProof: IDscCircuitVerifier.DscCircuitProofStruct - ], - [void], - "nonpayable" - >; - - registry: TypedContractMethod<[attestationId: BytesLike], [string], "view">; - - renounceOwnership: TypedContractMethod<[], [void], "nonpayable">; - - rootTimestamp: TypedContractMethod< - [attestationId: BytesLike, root: BigNumberish], - [bigint], - "view" - >; - - setVerificationConfigV2: TypedContractMethod< - [config: SelfStructs.VerificationConfigV2Struct], - [string], - "nonpayable" - >; - - transferOwnership: TypedContractMethod< - [newOwner: AddressLike], - [void], - "nonpayable" - >; - - updateDscVerifier: TypedContractMethod< - [ - attestationId: BytesLike, - typeId: BigNumberish, - verifierAddress: AddressLike - ], - [void], - "nonpayable" - >; - - updateRegisterCircuitVerifier: TypedContractMethod< - [ - attestationId: BytesLike, - typeId: BigNumberish, - verifierAddress: AddressLike - ], - [void], - "nonpayable" - >; - - updateRegistry: TypedContractMethod< - [attestationId: BytesLike, registryAddress: AddressLike], - [void], - "nonpayable" - >; - - updateVcAndDiscloseCircuit: TypedContractMethod< - [ - attestationId: BytesLike, - vcAndDiscloseCircuitVerifierAddress: AddressLike - ], - [void], - "nonpayable" - >; - - upgradeToAndCall: TypedContractMethod< - [newImplementation: AddressLike, data: BytesLike], - [void], - "payable" - >; - - verificationConfigV2Exists: TypedContractMethod< - [configId: BytesLike], - [boolean], - "view" - >; - - verify: TypedContractMethod< - [baseVerificationInput: BytesLike, userContextData: BytesLike], - [void], - "nonpayable" - >; - - getFunction( - key: string | FunctionFragment - ): T; - - getFunction( - nameOrSignature: "UPGRADE_INTERFACE_VERSION" - ): TypedContractMethod<[], [string], "view">; - getFunction( - nameOrSignature: "acceptOwnership" - ): TypedContractMethod<[], [void], "nonpayable">; - getFunction( - nameOrSignature: "batchUpdateDscCircuitVerifiers" - ): TypedContractMethod< - [ - attestationIds: BytesLike[], - typeIds: BigNumberish[], - verifierAddresses: AddressLike[] - ], - [void], - "nonpayable" - >; - getFunction( - nameOrSignature: "batchUpdateRegisterCircuitVerifiers" - ): TypedContractMethod< - [ - attestationIds: BytesLike[], - typeIds: BigNumberish[], - verifierAddresses: AddressLike[] - ], - [void], - "nonpayable" - >; - getFunction( - nameOrSignature: "discloseVerifier" - ): TypedContractMethod<[attestationId: BytesLike], [string], "view">; - getFunction( - nameOrSignature: "dscCircuitVerifiers" - ): TypedContractMethod< - [attestationId: BytesLike, typeId: BigNumberish], - [string], - "view" - >; - getFunction( - nameOrSignature: "generateConfigId" - ): TypedContractMethod< - [config: SelfStructs.VerificationConfigV2Struct], - [string], - "view" - >; - getFunction( - nameOrSignature: "getIdentityCommitmentMerkleRoot" - ): TypedContractMethod<[attestationId: BytesLike], [bigint], "view">; - getFunction( - nameOrSignature: "initialize" - ): TypedContractMethod<[], [void], "nonpayable">; - getFunction( - nameOrSignature: "owner" - ): TypedContractMethod<[], [string], "view">; - getFunction( - nameOrSignature: "pendingOwner" - ): TypedContractMethod<[], [string], "view">; - getFunction( - nameOrSignature: "proxiableUUID" - ): TypedContractMethod<[], [string], "view">; - getFunction( - nameOrSignature: "registerCircuitVerifiers" - ): TypedContractMethod< - [attestationId: BytesLike, typeId: BigNumberish], - [string], - "view" - >; - getFunction( - nameOrSignature: "registerCommitment" - ): TypedContractMethod< - [ - attestationId: BytesLike, - registerCircuitVerifierId: BigNumberish, - registerCircuitProof: IRegisterCircuitVerifier.RegisterCircuitProofStruct - ], - [void], - "nonpayable" - >; - getFunction( - nameOrSignature: "registerDscKeyCommitment" - ): TypedContractMethod< - [ - attestationId: BytesLike, - dscCircuitVerifierId: BigNumberish, - dscCircuitProof: IDscCircuitVerifier.DscCircuitProofStruct - ], - [void], - "nonpayable" - >; - getFunction( - nameOrSignature: "registry" - ): TypedContractMethod<[attestationId: BytesLike], [string], "view">; - getFunction( - nameOrSignature: "renounceOwnership" - ): TypedContractMethod<[], [void], "nonpayable">; - getFunction( - nameOrSignature: "rootTimestamp" - ): TypedContractMethod< - [attestationId: BytesLike, root: BigNumberish], - [bigint], - "view" - >; - getFunction( - nameOrSignature: "setVerificationConfigV2" - ): TypedContractMethod< - [config: SelfStructs.VerificationConfigV2Struct], - [string], - "nonpayable" - >; - getFunction( - nameOrSignature: "transferOwnership" - ): TypedContractMethod<[newOwner: AddressLike], [void], "nonpayable">; - getFunction( - nameOrSignature: "updateDscVerifier" - ): TypedContractMethod< - [ - attestationId: BytesLike, - typeId: BigNumberish, - verifierAddress: AddressLike - ], - [void], - "nonpayable" - >; - getFunction( - nameOrSignature: "updateRegisterCircuitVerifier" - ): TypedContractMethod< - [ - attestationId: BytesLike, - typeId: BigNumberish, - verifierAddress: AddressLike - ], - [void], - "nonpayable" - >; - getFunction( - nameOrSignature: "updateRegistry" - ): TypedContractMethod< - [attestationId: BytesLike, registryAddress: AddressLike], - [void], - "nonpayable" - >; - getFunction( - nameOrSignature: "updateVcAndDiscloseCircuit" - ): TypedContractMethod< - [ - attestationId: BytesLike, - vcAndDiscloseCircuitVerifierAddress: AddressLike - ], - [void], - "nonpayable" - >; - getFunction( - nameOrSignature: "upgradeToAndCall" - ): TypedContractMethod< - [newImplementation: AddressLike, data: BytesLike], - [void], - "payable" - >; - getFunction( - nameOrSignature: "verificationConfigV2Exists" - ): TypedContractMethod<[configId: BytesLike], [boolean], "view">; - getFunction( - nameOrSignature: "verify" - ): TypedContractMethod< - [baseVerificationInput: BytesLike, userContextData: BytesLike], - [void], - "nonpayable" - >; - - getEvent( - key: "DscCircuitVerifierUpdated" - ): TypedContractEvent< - DscCircuitVerifierUpdatedEvent.InputTuple, - DscCircuitVerifierUpdatedEvent.OutputTuple, - DscCircuitVerifierUpdatedEvent.OutputObject - >; - getEvent( - key: "HubInitializedV2" - ): TypedContractEvent< - HubInitializedV2Event.InputTuple, - HubInitializedV2Event.OutputTuple, - HubInitializedV2Event.OutputObject - >; - getEvent( - key: "Initialized" - ): TypedContractEvent< - InitializedEvent.InputTuple, - InitializedEvent.OutputTuple, - InitializedEvent.OutputObject - >; - getEvent( - key: "OwnershipTransferStarted" - ): TypedContractEvent< - OwnershipTransferStartedEvent.InputTuple, - OwnershipTransferStartedEvent.OutputTuple, - OwnershipTransferStartedEvent.OutputObject - >; - getEvent( - key: "OwnershipTransferred" - ): TypedContractEvent< - OwnershipTransferredEvent.InputTuple, - OwnershipTransferredEvent.OutputTuple, - OwnershipTransferredEvent.OutputObject - >; - getEvent( - key: "RegisterCircuitVerifierUpdated" - ): TypedContractEvent< - RegisterCircuitVerifierUpdatedEvent.InputTuple, - RegisterCircuitVerifierUpdatedEvent.OutputTuple, - RegisterCircuitVerifierUpdatedEvent.OutputObject - >; - getEvent( - key: "RegistryUpdated" - ): TypedContractEvent< - RegistryUpdatedEvent.InputTuple, - RegistryUpdatedEvent.OutputTuple, - RegistryUpdatedEvent.OutputObject - >; - getEvent( - key: "Upgraded" - ): TypedContractEvent< - UpgradedEvent.InputTuple, - UpgradedEvent.OutputTuple, - UpgradedEvent.OutputObject - >; - getEvent( - key: "VcAndDiscloseCircuitUpdated" - ): TypedContractEvent< - VcAndDiscloseCircuitUpdatedEvent.InputTuple, - VcAndDiscloseCircuitUpdatedEvent.OutputTuple, - VcAndDiscloseCircuitUpdatedEvent.OutputObject - >; - getEvent( - key: "VerificationConfigV2Set" - ): TypedContractEvent< - VerificationConfigV2SetEvent.InputTuple, - VerificationConfigV2SetEvent.OutputTuple, - VerificationConfigV2SetEvent.OutputObject - >; - - filters: { - "DscCircuitVerifierUpdated(uint256,address)": TypedContractEvent< - DscCircuitVerifierUpdatedEvent.InputTuple, - DscCircuitVerifierUpdatedEvent.OutputTuple, - DscCircuitVerifierUpdatedEvent.OutputObject - >; - DscCircuitVerifierUpdated: TypedContractEvent< - DscCircuitVerifierUpdatedEvent.InputTuple, - DscCircuitVerifierUpdatedEvent.OutputTuple, - DscCircuitVerifierUpdatedEvent.OutputObject - >; - - "HubInitializedV2()": TypedContractEvent< - HubInitializedV2Event.InputTuple, - HubInitializedV2Event.OutputTuple, - HubInitializedV2Event.OutputObject - >; - HubInitializedV2: TypedContractEvent< - HubInitializedV2Event.InputTuple, - HubInitializedV2Event.OutputTuple, - HubInitializedV2Event.OutputObject - >; - - "Initialized(uint64)": TypedContractEvent< - InitializedEvent.InputTuple, - InitializedEvent.OutputTuple, - InitializedEvent.OutputObject - >; - Initialized: TypedContractEvent< - InitializedEvent.InputTuple, - InitializedEvent.OutputTuple, - InitializedEvent.OutputObject - >; - - "OwnershipTransferStarted(address,address)": TypedContractEvent< - OwnershipTransferStartedEvent.InputTuple, - OwnershipTransferStartedEvent.OutputTuple, - OwnershipTransferStartedEvent.OutputObject - >; - OwnershipTransferStarted: TypedContractEvent< - OwnershipTransferStartedEvent.InputTuple, - OwnershipTransferStartedEvent.OutputTuple, - OwnershipTransferStartedEvent.OutputObject - >; - - "OwnershipTransferred(address,address)": TypedContractEvent< - OwnershipTransferredEvent.InputTuple, - OwnershipTransferredEvent.OutputTuple, - OwnershipTransferredEvent.OutputObject - >; - OwnershipTransferred: TypedContractEvent< - OwnershipTransferredEvent.InputTuple, - OwnershipTransferredEvent.OutputTuple, - OwnershipTransferredEvent.OutputObject - >; - - "RegisterCircuitVerifierUpdated(uint256,address)": TypedContractEvent< - RegisterCircuitVerifierUpdatedEvent.InputTuple, - RegisterCircuitVerifierUpdatedEvent.OutputTuple, - RegisterCircuitVerifierUpdatedEvent.OutputObject - >; - RegisterCircuitVerifierUpdated: TypedContractEvent< - RegisterCircuitVerifierUpdatedEvent.InputTuple, - RegisterCircuitVerifierUpdatedEvent.OutputTuple, - RegisterCircuitVerifierUpdatedEvent.OutputObject - >; - - "RegistryUpdated(bytes32,address)": TypedContractEvent< - RegistryUpdatedEvent.InputTuple, - RegistryUpdatedEvent.OutputTuple, - RegistryUpdatedEvent.OutputObject - >; - RegistryUpdated: TypedContractEvent< - RegistryUpdatedEvent.InputTuple, - RegistryUpdatedEvent.OutputTuple, - RegistryUpdatedEvent.OutputObject - >; - - "Upgraded(address)": TypedContractEvent< - UpgradedEvent.InputTuple, - UpgradedEvent.OutputTuple, - UpgradedEvent.OutputObject - >; - Upgraded: TypedContractEvent< - UpgradedEvent.InputTuple, - UpgradedEvent.OutputTuple, - UpgradedEvent.OutputObject - >; - - "VcAndDiscloseCircuitUpdated(bytes32,address)": TypedContractEvent< - VcAndDiscloseCircuitUpdatedEvent.InputTuple, - VcAndDiscloseCircuitUpdatedEvent.OutputTuple, - VcAndDiscloseCircuitUpdatedEvent.OutputObject - >; - VcAndDiscloseCircuitUpdated: TypedContractEvent< - VcAndDiscloseCircuitUpdatedEvent.InputTuple, - VcAndDiscloseCircuitUpdatedEvent.OutputTuple, - VcAndDiscloseCircuitUpdatedEvent.OutputObject - >; - - "VerificationConfigV2Set(bytes32,tuple)": TypedContractEvent< - VerificationConfigV2SetEvent.InputTuple, - VerificationConfigV2SetEvent.OutputTuple, - VerificationConfigV2SetEvent.OutputObject - >; - VerificationConfigV2Set: TypedContractEvent< - VerificationConfigV2SetEvent.InputTuple, - VerificationConfigV2SetEvent.OutputTuple, - VerificationConfigV2SetEvent.OutputObject - >; - }; -} diff --git a/sdk/core/src/typechain-types/Registry.ts b/sdk/core/src/typechain-types/Registry.ts deleted file mode 100644 index 57a2cc009..000000000 --- a/sdk/core/src/typechain-types/Registry.ts +++ /dev/null @@ -1,95 +0,0 @@ -/* Autogenerated file. Do not edit manually. */ -/* tslint:disable */ -/* eslint-disable */ -import type { - BaseContract, - BigNumberish, - BytesLike, - FunctionFragment, - Result, - Interface, - ContractRunner, - ContractMethod, - Listener, -} from "ethers"; -import type { - TypedContractEvent, - TypedDeferredTopicFilter, - TypedEventLog, - TypedListener, - TypedContractMethod, -} from "./common.js"; - -export interface RegistryInterface extends Interface { - getFunction(nameOrSignature: "checkIdentityCommitmentRoot"): FunctionFragment; - - encodeFunctionData( - functionFragment: "checkIdentityCommitmentRoot", - values: [BigNumberish] - ): string; - - decodeFunctionResult( - functionFragment: "checkIdentityCommitmentRoot", - data: BytesLike - ): Result; -} - -export interface Registry extends BaseContract { - connect(runner?: ContractRunner | null): Registry; - waitForDeployment(): Promise; - - interface: RegistryInterface; - - queryFilter( - event: TCEvent, - fromBlockOrBlockhash?: string | number | undefined, - toBlock?: string | number | undefined - ): Promise>>; - queryFilter( - filter: TypedDeferredTopicFilter, - fromBlockOrBlockhash?: string | number | undefined, - toBlock?: string | number | undefined - ): Promise>>; - - on( - event: TCEvent, - listener: TypedListener - ): Promise; - on( - filter: TypedDeferredTopicFilter, - listener: TypedListener - ): Promise; - - once( - event: TCEvent, - listener: TypedListener - ): Promise; - once( - filter: TypedDeferredTopicFilter, - listener: TypedListener - ): Promise; - - listeners( - event: TCEvent - ): Promise>>; - listeners(eventName?: string): Promise>; - removeAllListeners( - event?: TCEvent - ): Promise; - - checkIdentityCommitmentRoot: TypedContractMethod< - [root: BigNumberish], - [boolean], - "view" - >; - - getFunction( - key: string | FunctionFragment - ): T; - - getFunction( - nameOrSignature: "checkIdentityCommitmentRoot" - ): TypedContractMethod<[root: BigNumberish], [boolean], "view">; - - filters: {}; -} diff --git a/sdk/core/src/typechain-types/Verifier.ts b/sdk/core/src/typechain-types/Verifier.ts deleted file mode 100644 index 4b7200bea..000000000 --- a/sdk/core/src/typechain-types/Verifier.ts +++ /dev/null @@ -1,114 +0,0 @@ -/* Autogenerated file. Do not edit manually. */ -/* tslint:disable */ -/* eslint-disable */ -import type { - BaseContract, - BigNumberish, - BytesLike, - FunctionFragment, - Result, - Interface, - ContractRunner, - ContractMethod, - Listener, -} from "ethers"; -import type { - TypedContractEvent, - TypedDeferredTopicFilter, - TypedEventLog, - TypedListener, - TypedContractMethod, -} from "./common.js"; - -export interface VerifierInterface extends Interface { - getFunction(nameOrSignature: "verifyProof"): FunctionFragment; - - encodeFunctionData( - functionFragment: "verifyProof", - values: [ - [BigNumberish, BigNumberish], - [[BigNumberish, BigNumberish], [BigNumberish, BigNumberish]], - [BigNumberish, BigNumberish], - BigNumberish[] - ] - ): string; - - decodeFunctionResult( - functionFragment: "verifyProof", - data: BytesLike - ): Result; -} - -export interface Verifier extends BaseContract { - connect(runner?: ContractRunner | null): Verifier; - waitForDeployment(): Promise; - - interface: VerifierInterface; - - queryFilter( - event: TCEvent, - fromBlockOrBlockhash?: string | number | undefined, - toBlock?: string | number | undefined - ): Promise>>; - queryFilter( - filter: TypedDeferredTopicFilter, - fromBlockOrBlockhash?: string | number | undefined, - toBlock?: string | number | undefined - ): Promise>>; - - on( - event: TCEvent, - listener: TypedListener - ): Promise; - on( - filter: TypedDeferredTopicFilter, - listener: TypedListener - ): Promise; - - once( - event: TCEvent, - listener: TypedListener - ): Promise; - once( - filter: TypedDeferredTopicFilter, - listener: TypedListener - ): Promise; - - listeners( - event: TCEvent - ): Promise>>; - listeners(eventName?: string): Promise>; - removeAllListeners( - event?: TCEvent - ): Promise; - - verifyProof: TypedContractMethod< - [ - a: [BigNumberish, BigNumberish], - b: [[BigNumberish, BigNumberish], [BigNumberish, BigNumberish]], - c: [BigNumberish, BigNumberish], - pubSignals: BigNumberish[] - ], - [boolean], - "view" - >; - - getFunction( - key: string | FunctionFragment - ): T; - - getFunction( - nameOrSignature: "verifyProof" - ): TypedContractMethod< - [ - a: [BigNumberish, BigNumberish], - b: [[BigNumberish, BigNumberish], [BigNumberish, BigNumberish]], - c: [BigNumberish, BigNumberish], - pubSignals: BigNumberish[] - ], - [boolean], - "view" - >; - - filters: {}; -} diff --git a/sdk/core/src/typechain-types/common.ts b/sdk/core/src/typechain-types/common.ts deleted file mode 100644 index 56b5f21e9..000000000 --- a/sdk/core/src/typechain-types/common.ts +++ /dev/null @@ -1,131 +0,0 @@ -/* Autogenerated file. Do not edit manually. */ -/* tslint:disable */ -/* eslint-disable */ -import type { - FunctionFragment, - Typed, - EventFragment, - ContractTransaction, - ContractTransactionResponse, - DeferredTopicFilter, - EventLog, - TransactionRequest, - LogDescription, -} from "ethers"; - -export interface TypedDeferredTopicFilter<_TCEvent extends TypedContractEvent> - extends DeferredTopicFilter {} - -export interface TypedContractEvent< - InputTuple extends Array = any, - OutputTuple extends Array = any, - OutputObject = any -> { - (...args: Partial): TypedDeferredTopicFilter< - TypedContractEvent - >; - name: string; - fragment: EventFragment; - getFragment(...args: Partial): EventFragment; -} - -type __TypechainAOutputTuple = T extends TypedContractEvent< - infer _U, - infer W -> - ? W - : never; -type __TypechainOutputObject = T extends TypedContractEvent< - infer _U, - infer _W, - infer V -> - ? V - : never; - -export interface TypedEventLog - extends Omit { - args: __TypechainAOutputTuple & __TypechainOutputObject; -} - -export interface TypedLogDescription - extends Omit { - args: __TypechainAOutputTuple & __TypechainOutputObject; -} - -export type TypedListener = ( - ...listenerArg: [ - ...__TypechainAOutputTuple, - TypedEventLog, - ...undefined[] - ] -) => void; - -export type MinEthersFactory = { - deploy(...a: ARGS[]): Promise; -}; - -export type GetContractTypeFromFactory = F extends MinEthersFactory< - infer C, - any -> - ? C - : never; -export type GetARGsTypeFromFactory = F extends MinEthersFactory - ? Parameters - : never; - -export type StateMutability = "nonpayable" | "payable" | "view"; - -export type BaseOverrides = Omit; -export type NonPayableOverrides = Omit< - BaseOverrides, - "value" | "blockTag" | "enableCcipRead" ->; -export type PayableOverrides = Omit< - BaseOverrides, - "blockTag" | "enableCcipRead" ->; -export type ViewOverrides = Omit; -export type Overrides = S extends "nonpayable" - ? NonPayableOverrides - : S extends "payable" - ? PayableOverrides - : ViewOverrides; - -export type PostfixOverrides, S extends StateMutability> = - | A - | [...A, Overrides]; -export type ContractMethodArgs< - A extends Array, - S extends StateMutability -> = PostfixOverrides<{ [I in keyof A]-?: A[I] | Typed }, S>; - -export type DefaultReturnType = R extends Array ? R[0] : R; - -// export interface ContractMethod = Array, R = any, D extends R | ContractTransactionResponse = R | ContractTransactionResponse> { -export interface TypedContractMethod< - A extends Array = Array, - R = any, - S extends StateMutability = "payable" -> { - (...args: ContractMethodArgs): S extends "view" - ? Promise> - : Promise; - - name: string; - - fragment: FunctionFragment; - - getFragment(...args: ContractMethodArgs): FunctionFragment; - - populateTransaction( - ...args: ContractMethodArgs - ): Promise; - staticCall( - ...args: ContractMethodArgs - ): Promise>; - send(...args: ContractMethodArgs): Promise; - estimateGas(...args: ContractMethodArgs): Promise; - staticCallResult(...args: ContractMethodArgs): Promise; -} diff --git a/sdk/core/src/typechain-types/factories/IdentityVerificationHubImpl__factory.ts b/sdk/core/src/typechain-types/factories/IdentityVerificationHubImpl__factory.ts deleted file mode 100644 index cb238dd6d..000000000 --- a/sdk/core/src/typechain-types/factories/IdentityVerificationHubImpl__factory.ts +++ /dev/null @@ -1,991 +0,0 @@ -/* Autogenerated file. Do not edit manually. */ -/* tslint:disable */ -/* eslint-disable */ - -import { Contract, Interface, type ContractRunner } from "ethers"; -import type { - IdentityVerificationHubImpl, - IdentityVerificationHubImplInterface, -} from "../IdentityVerificationHubImpl.js"; - -const _abi = [ - { - inputs: [], - stateMutability: "nonpayable", - type: "constructor", - }, - { - inputs: [ - { - internalType: "address", - name: "target", - type: "address", - }, - ], - name: "AddressEmptyCode", - type: "error", - }, - { - inputs: [], - name: "CrossChainIsNotSupportedYet", - type: "error", - }, - { - inputs: [], - name: "CurrentDateNotInValidRange", - type: "error", - }, - { - inputs: [ - { - internalType: "address", - name: "implementation", - type: "address", - }, - ], - name: "ERC1967InvalidImplementation", - type: "error", - }, - { - inputs: [], - name: "ERC1967NonPayable", - type: "error", - }, - { - inputs: [], - name: "FailedCall", - type: "error", - }, - { - inputs: [], - name: "InputTooShort", - type: "error", - }, - { - inputs: [], - name: "InvalidAttestationId", - type: "error", - }, - { - inputs: [], - name: "InvalidCscaRoot", - type: "error", - }, - { - inputs: [], - name: "InvalidDateDigit", - type: "error", - }, - { - inputs: [], - name: "InvalidDateLength", - type: "error", - }, - { - inputs: [], - name: "InvalidDayRange", - type: "error", - }, - { - inputs: [], - name: "InvalidDscCommitmentRoot", - type: "error", - }, - { - inputs: [], - name: "InvalidDscProof", - type: "error", - }, - { - inputs: [], - name: "InvalidFieldElement", - type: "error", - }, - { - inputs: [], - name: "InvalidIdentityCommitmentRoot", - type: "error", - }, - { - inputs: [], - name: "InvalidInitialization", - type: "error", - }, - { - inputs: [], - name: "InvalidMonthRange", - type: "error", - }, - { - inputs: [], - name: "InvalidRegisterProof", - type: "error", - }, - { - inputs: [], - name: "InvalidUserIdentifierInProof", - type: "error", - }, - { - inputs: [], - name: "InvalidVcAndDiscloseProof", - type: "error", - }, - { - inputs: [], - name: "InvalidYearRange", - type: "error", - }, - { - inputs: [], - name: "LengthMismatch", - type: "error", - }, - { - inputs: [], - name: "NoVerifierSet", - type: "error", - }, - { - inputs: [], - name: "NotInitializing", - type: "error", - }, - { - inputs: [ - { - internalType: "address", - name: "owner", - type: "address", - }, - ], - name: "OwnableInvalidOwner", - type: "error", - }, - { - inputs: [ - { - internalType: "address", - name: "account", - type: "address", - }, - ], - name: "OwnableUnauthorizedAccount", - type: "error", - }, - { - inputs: [], - name: "ScopeMismatch", - type: "error", - }, - { - inputs: [], - name: "UUPSUnauthorizedCallContext", - type: "error", - }, - { - inputs: [ - { - internalType: "bytes32", - name: "slot", - type: "bytes32", - }, - ], - name: "UUPSUnsupportedProxiableUUID", - type: "error", - }, - { - inputs: [], - name: "UserContextDataTooShort", - type: "error", - }, - { - anonymous: false, - inputs: [ - { - indexed: false, - internalType: "uint256", - name: "typeId", - type: "uint256", - }, - { - indexed: false, - internalType: "address", - name: "verifier", - type: "address", - }, - ], - name: "DscCircuitVerifierUpdated", - type: "event", - }, - { - anonymous: false, - inputs: [], - name: "HubInitializedV2", - type: "event", - }, - { - anonymous: false, - inputs: [ - { - indexed: false, - internalType: "uint64", - name: "version", - type: "uint64", - }, - ], - name: "Initialized", - type: "event", - }, - { - anonymous: false, - inputs: [ - { - indexed: true, - internalType: "address", - name: "previousOwner", - type: "address", - }, - { - indexed: true, - internalType: "address", - name: "newOwner", - type: "address", - }, - ], - name: "OwnershipTransferStarted", - type: "event", - }, - { - anonymous: false, - inputs: [ - { - indexed: true, - internalType: "address", - name: "previousOwner", - type: "address", - }, - { - indexed: true, - internalType: "address", - name: "newOwner", - type: "address", - }, - ], - name: "OwnershipTransferred", - type: "event", - }, - { - anonymous: false, - inputs: [ - { - indexed: false, - internalType: "uint256", - name: "typeId", - type: "uint256", - }, - { - indexed: false, - internalType: "address", - name: "verifier", - type: "address", - }, - ], - name: "RegisterCircuitVerifierUpdated", - type: "event", - }, - { - anonymous: false, - inputs: [ - { - indexed: false, - internalType: "bytes32", - name: "attestationId", - type: "bytes32", - }, - { - indexed: false, - internalType: "address", - name: "registry", - type: "address", - }, - ], - name: "RegistryUpdated", - type: "event", - }, - { - anonymous: false, - inputs: [ - { - indexed: true, - internalType: "address", - name: "implementation", - type: "address", - }, - ], - name: "Upgraded", - type: "event", - }, - { - anonymous: false, - inputs: [ - { - indexed: false, - internalType: "bytes32", - name: "attestationId", - type: "bytes32", - }, - { - indexed: false, - internalType: "address", - name: "vcAndDiscloseCircuitVerifier", - type: "address", - }, - ], - name: "VcAndDiscloseCircuitUpdated", - type: "event", - }, - { - anonymous: false, - inputs: [ - { - indexed: true, - internalType: "bytes32", - name: "configId", - type: "bytes32", - }, - { - components: [ - { - internalType: "bool", - name: "olderThanEnabled", - type: "bool", - }, - { - internalType: "uint256", - name: "olderThan", - type: "uint256", - }, - { - internalType: "bool", - name: "forbiddenCountriesEnabled", - type: "bool", - }, - { - internalType: "uint256[4]", - name: "forbiddenCountriesListPacked", - type: "uint256[4]", - }, - { - internalType: "bool[3]", - name: "ofacEnabled", - type: "bool[3]", - }, - ], - indexed: false, - internalType: "struct SelfStructs.VerificationConfigV2", - name: "config", - type: "tuple", - }, - ], - name: "VerificationConfigV2Set", - type: "event", - }, - { - inputs: [], - name: "UPGRADE_INTERFACE_VERSION", - outputs: [ - { - internalType: "string", - name: "", - type: "string", - }, - ], - stateMutability: "view", - type: "function", - }, - { - inputs: [], - name: "acceptOwnership", - outputs: [], - stateMutability: "nonpayable", - type: "function", - }, - { - inputs: [ - { - internalType: "bytes32[]", - name: "attestationIds", - type: "bytes32[]", - }, - { - internalType: "uint256[]", - name: "typeIds", - type: "uint256[]", - }, - { - internalType: "address[]", - name: "verifierAddresses", - type: "address[]", - }, - ], - name: "batchUpdateDscCircuitVerifiers", - outputs: [], - stateMutability: "nonpayable", - type: "function", - }, - { - inputs: [ - { - internalType: "bytes32[]", - name: "attestationIds", - type: "bytes32[]", - }, - { - internalType: "uint256[]", - name: "typeIds", - type: "uint256[]", - }, - { - internalType: "address[]", - name: "verifierAddresses", - type: "address[]", - }, - ], - name: "batchUpdateRegisterCircuitVerifiers", - outputs: [], - stateMutability: "nonpayable", - type: "function", - }, - { - inputs: [ - { - internalType: "bytes32", - name: "attestationId", - type: "bytes32", - }, - ], - name: "discloseVerifier", - outputs: [ - { - internalType: "address", - name: "", - type: "address", - }, - ], - stateMutability: "view", - type: "function", - }, - { - inputs: [ - { - internalType: "bytes32", - name: "attestationId", - type: "bytes32", - }, - { - internalType: "uint256", - name: "typeId", - type: "uint256", - }, - ], - name: "dscCircuitVerifiers", - outputs: [ - { - internalType: "address", - name: "", - type: "address", - }, - ], - stateMutability: "view", - type: "function", - }, - { - inputs: [ - { - components: [ - { - internalType: "bool", - name: "olderThanEnabled", - type: "bool", - }, - { - internalType: "uint256", - name: "olderThan", - type: "uint256", - }, - { - internalType: "bool", - name: "forbiddenCountriesEnabled", - type: "bool", - }, - { - internalType: "uint256[4]", - name: "forbiddenCountriesListPacked", - type: "uint256[4]", - }, - { - internalType: "bool[3]", - name: "ofacEnabled", - type: "bool[3]", - }, - ], - internalType: "struct SelfStructs.VerificationConfigV2", - name: "config", - type: "tuple", - }, - ], - name: "generateConfigId", - outputs: [ - { - internalType: "bytes32", - name: "", - type: "bytes32", - }, - ], - stateMutability: "pure", - type: "function", - }, - { - inputs: [ - { - internalType: "bytes32", - name: "attestationId", - type: "bytes32", - }, - ], - name: "getIdentityCommitmentMerkleRoot", - outputs: [ - { - internalType: "uint256", - name: "", - type: "uint256", - }, - ], - stateMutability: "view", - type: "function", - }, - { - inputs: [], - name: "initialize", - outputs: [], - stateMutability: "nonpayable", - type: "function", - }, - { - inputs: [], - name: "owner", - outputs: [ - { - internalType: "address", - name: "", - type: "address", - }, - ], - stateMutability: "view", - type: "function", - }, - { - inputs: [], - name: "pendingOwner", - outputs: [ - { - internalType: "address", - name: "", - type: "address", - }, - ], - stateMutability: "view", - type: "function", - }, - { - inputs: [], - name: "proxiableUUID", - outputs: [ - { - internalType: "bytes32", - name: "", - type: "bytes32", - }, - ], - stateMutability: "view", - type: "function", - }, - { - inputs: [ - { - internalType: "bytes32", - name: "attestationId", - type: "bytes32", - }, - { - internalType: "uint256", - name: "typeId", - type: "uint256", - }, - ], - name: "registerCircuitVerifiers", - outputs: [ - { - internalType: "address", - name: "", - type: "address", - }, - ], - stateMutability: "view", - type: "function", - }, - { - inputs: [ - { - internalType: "bytes32", - name: "attestationId", - type: "bytes32", - }, - { - internalType: "uint256", - name: "registerCircuitVerifierId", - type: "uint256", - }, - { - components: [ - { - internalType: "uint256[2]", - name: "a", - type: "uint256[2]", - }, - { - internalType: "uint256[2][2]", - name: "b", - type: "uint256[2][2]", - }, - { - internalType: "uint256[2]", - name: "c", - type: "uint256[2]", - }, - { - internalType: "uint256[3]", - name: "pubSignals", - type: "uint256[3]", - }, - ], - internalType: "struct IRegisterCircuitVerifier.RegisterCircuitProof", - name: "registerCircuitProof", - type: "tuple", - }, - ], - name: "registerCommitment", - outputs: [], - stateMutability: "nonpayable", - type: "function", - }, - { - inputs: [ - { - internalType: "bytes32", - name: "attestationId", - type: "bytes32", - }, - { - internalType: "uint256", - name: "dscCircuitVerifierId", - type: "uint256", - }, - { - components: [ - { - internalType: "uint256[2]", - name: "a", - type: "uint256[2]", - }, - { - internalType: "uint256[2][2]", - name: "b", - type: "uint256[2][2]", - }, - { - internalType: "uint256[2]", - name: "c", - type: "uint256[2]", - }, - { - internalType: "uint256[2]", - name: "pubSignals", - type: "uint256[2]", - }, - ], - internalType: "struct IDscCircuitVerifier.DscCircuitProof", - name: "dscCircuitProof", - type: "tuple", - }, - ], - name: "registerDscKeyCommitment", - outputs: [], - stateMutability: "nonpayable", - type: "function", - }, - { - inputs: [ - { - internalType: "bytes32", - name: "attestationId", - type: "bytes32", - }, - ], - name: "registry", - outputs: [ - { - internalType: "address", - name: "", - type: "address", - }, - ], - stateMutability: "view", - type: "function", - }, - { - inputs: [], - name: "renounceOwnership", - outputs: [], - stateMutability: "nonpayable", - type: "function", - }, - { - inputs: [ - { - internalType: "bytes32", - name: "attestationId", - type: "bytes32", - }, - { - internalType: "uint256", - name: "root", - type: "uint256", - }, - ], - name: "rootTimestamp", - outputs: [ - { - internalType: "uint256", - name: "", - type: "uint256", - }, - ], - stateMutability: "view", - type: "function", - }, - { - inputs: [ - { - components: [ - { - internalType: "bool", - name: "olderThanEnabled", - type: "bool", - }, - { - internalType: "uint256", - name: "olderThan", - type: "uint256", - }, - { - internalType: "bool", - name: "forbiddenCountriesEnabled", - type: "bool", - }, - { - internalType: "uint256[4]", - name: "forbiddenCountriesListPacked", - type: "uint256[4]", - }, - { - internalType: "bool[3]", - name: "ofacEnabled", - type: "bool[3]", - }, - ], - internalType: "struct SelfStructs.VerificationConfigV2", - name: "config", - type: "tuple", - }, - ], - name: "setVerificationConfigV2", - outputs: [ - { - internalType: "bytes32", - name: "configId", - type: "bytes32", - }, - ], - stateMutability: "nonpayable", - type: "function", - }, - { - inputs: [ - { - internalType: "address", - name: "newOwner", - type: "address", - }, - ], - name: "transferOwnership", - outputs: [], - stateMutability: "nonpayable", - type: "function", - }, - { - inputs: [ - { - internalType: "bytes32", - name: "attestationId", - type: "bytes32", - }, - { - internalType: "uint256", - name: "typeId", - type: "uint256", - }, - { - internalType: "address", - name: "verifierAddress", - type: "address", - }, - ], - name: "updateDscVerifier", - outputs: [], - stateMutability: "nonpayable", - type: "function", - }, - { - inputs: [ - { - internalType: "bytes32", - name: "attestationId", - type: "bytes32", - }, - { - internalType: "uint256", - name: "typeId", - type: "uint256", - }, - { - internalType: "address", - name: "verifierAddress", - type: "address", - }, - ], - name: "updateRegisterCircuitVerifier", - outputs: [], - stateMutability: "nonpayable", - type: "function", - }, - { - inputs: [ - { - internalType: "bytes32", - name: "attestationId", - type: "bytes32", - }, - { - internalType: "address", - name: "registryAddress", - type: "address", - }, - ], - name: "updateRegistry", - outputs: [], - stateMutability: "nonpayable", - type: "function", - }, - { - inputs: [ - { - internalType: "bytes32", - name: "attestationId", - type: "bytes32", - }, - { - internalType: "address", - name: "vcAndDiscloseCircuitVerifierAddress", - type: "address", - }, - ], - name: "updateVcAndDiscloseCircuit", - outputs: [], - stateMutability: "nonpayable", - type: "function", - }, - { - inputs: [ - { - internalType: "address", - name: "newImplementation", - type: "address", - }, - { - internalType: "bytes", - name: "data", - type: "bytes", - }, - ], - name: "upgradeToAndCall", - outputs: [], - stateMutability: "payable", - type: "function", - }, - { - inputs: [ - { - internalType: "bytes32", - name: "configId", - type: "bytes32", - }, - ], - name: "verificationConfigV2Exists", - outputs: [ - { - internalType: "bool", - name: "exists", - type: "bool", - }, - ], - stateMutability: "view", - type: "function", - }, - { - inputs: [ - { - internalType: "bytes", - name: "baseVerificationInput", - type: "bytes", - }, - { - internalType: "bytes", - name: "userContextData", - type: "bytes", - }, - ], - name: "verify", - outputs: [], - stateMutability: "nonpayable", - type: "function", - }, -] as const; - -export class IdentityVerificationHubImpl__factory { - static readonly abi = _abi; - static createInterface(): IdentityVerificationHubImplInterface { - return new Interface(_abi) as IdentityVerificationHubImplInterface; - } - static connect( - address: string, - runner?: ContractRunner | null - ): IdentityVerificationHubImpl { - return new Contract( - address, - _abi, - runner - ) as unknown as IdentityVerificationHubImpl; - } -} diff --git a/sdk/core/src/typechain-types/factories/Registry__factory.ts b/sdk/core/src/typechain-types/factories/Registry__factory.ts deleted file mode 100644 index 3ef7941ea..000000000 --- a/sdk/core/src/typechain-types/factories/Registry__factory.ts +++ /dev/null @@ -1,38 +0,0 @@ -/* Autogenerated file. Do not edit manually. */ -/* tslint:disable */ -/* eslint-disable */ - -import { Contract, Interface, type ContractRunner } from "ethers"; -import type { Registry, RegistryInterface } from "../Registry.js"; - -const _abi = [ - { - inputs: [ - { - internalType: "uint256", - name: "root", - type: "uint256", - }, - ], - name: "checkIdentityCommitmentRoot", - outputs: [ - { - internalType: "bool", - name: "", - type: "bool", - }, - ], - stateMutability: "view", - type: "function", - }, -] as const; - -export class Registry__factory { - static readonly abi = _abi; - static createInterface(): RegistryInterface { - return new Interface(_abi) as RegistryInterface; - } - static connect(address: string, runner?: ContractRunner | null): Registry { - return new Contract(address, _abi, runner) as unknown as Registry; - } -} diff --git a/sdk/core/src/typechain-types/factories/Verifier__factory.ts b/sdk/core/src/typechain-types/factories/Verifier__factory.ts deleted file mode 100644 index 5e2c19f38..000000000 --- a/sdk/core/src/typechain-types/factories/Verifier__factory.ts +++ /dev/null @@ -1,53 +0,0 @@ -/* Autogenerated file. Do not edit manually. */ -/* tslint:disable */ -/* eslint-disable */ - -import { Contract, Interface, type ContractRunner } from "ethers"; -import type { Verifier, VerifierInterface } from "../Verifier.js"; - -const _abi = [ - { - inputs: [ - { - internalType: "uint256[2]", - name: "a", - type: "uint256[2]", - }, - { - internalType: "uint256[2][2]", - name: "b", - type: "uint256[2][2]", - }, - { - internalType: "uint256[2]", - name: "c", - type: "uint256[2]", - }, - { - internalType: "uint256[21]", - name: "pubSignals", - type: "uint256[21]", - }, - ], - name: "verifyProof", - outputs: [ - { - internalType: "bool", - name: "", - type: "bool", - }, - ], - stateMutability: "view", - type: "function", - }, -] as const; - -export class Verifier__factory { - static readonly abi = _abi; - static createInterface(): VerifierInterface { - return new Interface(_abi) as VerifierInterface; - } - static connect(address: string, runner?: ContractRunner | null): Verifier { - return new Contract(address, _abi, runner) as unknown as Verifier; - } -} diff --git a/sdk/core/src/typechain-types/factories/index.ts b/sdk/core/src/typechain-types/factories/index.ts deleted file mode 100644 index 8407f83a7..000000000 --- a/sdk/core/src/typechain-types/factories/index.ts +++ /dev/null @@ -1,6 +0,0 @@ -/* Autogenerated file. Do not edit manually. */ -/* tslint:disable */ -/* eslint-disable */ -export { IdentityVerificationHubImpl__factory } from "./IdentityVerificationHubImpl__factory.js"; -export { Registry__factory } from "./Registry__factory.js"; -export { Verifier__factory } from "./Verifier__factory.js"; diff --git a/sdk/core/src/typechain-types/index.ts b/sdk/core/src/typechain-types/index.ts deleted file mode 100644 index 9f484a67b..000000000 --- a/sdk/core/src/typechain-types/index.ts +++ /dev/null @@ -1,10 +0,0 @@ -/* Autogenerated file. Do not edit manually. */ -/* tslint:disable */ -/* eslint-disable */ -export type { IdentityVerificationHubImpl } from "./IdentityVerificationHubImpl.js"; -export type { Registry } from "./Registry.js"; -export type { Verifier } from "./Verifier.js"; -export * as factories from "./factories/index.js"; -export { IdentityVerificationHubImpl__factory } from "./factories/IdentityVerificationHubImpl__factory.js"; -export { Registry__factory } from "./factories/Registry__factory.js"; -export { Verifier__factory } from "./factories/Verifier__factory.js"; diff --git a/sdk/core/src/utils/id.ts b/sdk/core/src/utils/id.ts index 5c60cb45b..3044efffe 100644 --- a/sdk/core/src/utils/id.ts +++ b/sdk/core/src/utils/id.ts @@ -1,4 +1,5 @@ -import { AttestationId, discloseIndices, revealedDataIndices } from "./constants.js"; +import { discloseIndices, revealedDataIndices } from "./constants.js"; +import { AttestationId } from "src/types/types.js"; import { getRevealedDataBytes } from "./proof.js"; diff --git a/sdk/core/src/utils/proof.ts b/sdk/core/src/utils/proof.ts index efcfc1b79..be43104be 100644 --- a/sdk/core/src/utils/proof.ts +++ b/sdk/core/src/utils/proof.ts @@ -1,5 +1,6 @@ import { PublicSignals } from 'snarkjs'; -import { AttestationId, discloseIndices } from './constants.js'; +import { discloseIndices } from './constants.js'; +import { AttestationId } from 'src/types/types.js'; export function getRevealedDataPublicSignalsLength(attestationId: AttestationId): number { switch (attestationId) { @@ -26,17 +27,6 @@ export function getRevealedDataBytes(attestationId: AttestationId, publicSignals publicSignal = publicSignal >> 8n; } } - console.log(bytes); return bytes; } - -// export async function getUserIdentifier( -// publicSignals: PublicSignals, -// user_identifier_type: UserIdType = 'uuid' -// ): Promise { -// return castToUserIdentifier( -// BigInt(publicSignals[CIRCUIT_CONSTANTS.VC_AND_DISCLOSE_USER_IDENTIFIER_INDEX]), -// user_identifier_type -// ); -// } From 1639138590e77acfe539f9c8e898ab8ef1f2e4d2 Mon Sep 17 00:00:00 2001 From: Ayman Date: Fri, 20 Jun 2025 21:20:45 +0530 Subject: [PATCH 10/25] refactor --- sdk/core/src/SelfBackendVerifier.ts | 3 ++- sdk/core/src/types/types.ts | 24 ++++++++++++++++++++---- sdk/core/src/utils/id.ts | 17 +---------------- sdk/core/src/utils/utils.ts | 25 ++----------------------- 4 files changed, 25 insertions(+), 44 deletions(-) diff --git a/sdk/core/src/SelfBackendVerifier.ts b/sdk/core/src/SelfBackendVerifier.ts index 40e315526..8d1309ca0 100644 --- a/sdk/core/src/SelfBackendVerifier.ts +++ b/sdk/core/src/SelfBackendVerifier.ts @@ -40,6 +40,7 @@ export class SelfBackendVerifier { public async verify( attestationId: AttestationId, proof: VcAndDiscloseProof, + pubSignals: string[], userContextData: string, ) { //check if attestation id is allowed @@ -49,7 +50,7 @@ export class SelfBackendVerifier { issues.push({ type: ConfigMismatch.InvalidId, message: 'Attestation ID is not allowed' }); } - const publicSignals = proof.pubSignals.map(String).map((x) => /[a-f]/g.test(x) ? '0x' + x : x); + const publicSignals = pubSignals.map(String).map((x) => /[a-f]/g.test(x) ? '0x' + x : x); //check if user context hash matches const userContextHashInCircuit = publicSignals[discloseIndices[attestationId].userIdentifierIndex]; diff --git a/sdk/core/src/types/types.ts b/sdk/core/src/types/types.ts index 50f554672..c7e4cbe73 100644 --- a/sdk/core/src/types/types.ts +++ b/sdk/core/src/types/types.ts @@ -1,16 +1,32 @@ import type { BigNumberish } from 'ethers'; -import type { SelfStructs } from '../typechain-types/IdentityVerificationHubImpl.js'; import { discloseIndices } from 'src/utils/constants.js'; export type VcAndDiscloseProof = { a: [BigNumberish, BigNumberish]; b: [[BigNumberish, BigNumberish], [BigNumberish, BigNumberish]]; c: [BigNumberish, BigNumberish]; - pubSignals: BigNumberish[]; }; -export type VerificationConfig = SelfStructs.VerificationConfigV2Struct; +export type VerificationConfig = { + olderThanEnabled: boolean; + olderThan: string; + forbiddenCountriesEnabled: boolean; + forbiddenCountriesListPacked: string[]; + ofacEnabled: [boolean, boolean, boolean]; +}; -export type GenericDiscloseStruct = SelfStructs.VerificationConfigV2Struct; +export type GenericDiscloseOutput = { + nullifier: string; + forbiddenCountriesListPacked: string[]; + issuingState: string; + name: string; + idNumber: string; + nationality: string; + dateOfBirth: string; + gender: string; + expiryDate: string; + olderThan: string; + ofac: boolean[]; +} export type AttestationId = keyof typeof discloseIndices; diff --git a/sdk/core/src/utils/id.ts b/sdk/core/src/utils/id.ts index 3044efffe..1e4b13fc7 100644 --- a/sdk/core/src/utils/id.ts +++ b/sdk/core/src/utils/id.ts @@ -1,8 +1,7 @@ import { discloseIndices, revealedDataIndices } from "./constants.js"; -import { AttestationId } from "src/types/types.js"; +import { AttestationId, GenericDiscloseOutput } from "src/types/types.js"; import { getRevealedDataBytes } from "./proof.js"; - export const formatRevealedDataPacked = (attestationId: AttestationId, publicSignals: string[]): GenericDiscloseOutput => { const revealedDataPacked = getRevealedDataBytes(attestationId, publicSignals); const revealedDataPackedString = Buffer.from(revealedDataPacked); @@ -33,17 +32,3 @@ export const formatRevealedDataPacked = (attestationId: AttestationId, publicSig ofac: ofac, } }; - -type GenericDiscloseOutput = { - nullifier: string; - forbiddenCountriesListPacked: string[]; - issuingState: string; - name: string; - idNumber: string; - nationality: string; - dateOfBirth: string; - gender: string; - expiryDate: string; - olderThan: string; - ofac: boolean[]; -} diff --git a/sdk/core/src/utils/utils.ts b/sdk/core/src/utils/utils.ts index 5385aa87b..cc948e588 100644 --- a/sdk/core/src/utils/utils.ts +++ b/sdk/core/src/utils/utils.ts @@ -1,25 +1,4 @@ -export function unpackReveal( - revealedData_packed: string | string[], - id_type: 'passport' | 'id' -): string[] { - // If revealedData_packed is not an array, convert it to an array - const packedArray = Array.isArray(revealedData_packed) - ? revealedData_packed - : [revealedData_packed]; - - const bytesCount = id_type === 'passport' ? [31, 31, 31] : [31, 31, 31, 27]; // nb of bytes in each of the first three field elements - const bytesArray = packedArray.flatMap((element: string, index: number) => { - const bytes = bytesCount[index] || 31; // Use 31 as default if index is out of range - const elementBigInt = BigInt(element); - const byteMask = BigInt(255); // 0xFF - const bytesOfElement = [...Array(bytes)].map((_, byteIndex) => { - return (elementBigInt >> (BigInt(byteIndex) * BigInt(8))) & byteMask; - }); - return bytesOfElement; - }); - - return bytesArray.map((byte: bigint) => String.fromCharCode(Number(byte))); -} +import { unpackReveal } from "@selfxyz/common/utils/circuits/formatOutputs"; export function unpackForbiddenCountriesList(forbiddenCountriesList_packed: string[]) { const trimmed = unpackReveal(forbiddenCountriesList_packed, 'id'); @@ -30,5 +9,5 @@ export function unpackForbiddenCountriesList(forbiddenCountriesList_packed: stri countries.push(countryCode); } } - return countries; // Return countries array instead of trimmed + return countries; } From 9dcbc3c0cfbc42d6c1544e608a99e040807380fc Mon Sep 17 00:00:00 2001 From: Ayman Date: Fri, 20 Jun 2025 21:22:20 +0530 Subject: [PATCH 11/25] chore: rm unnecessary exports --- sdk/core/index.ts | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/sdk/core/index.ts b/sdk/core/index.ts index 97c76f4cb..bc8009b66 100644 --- a/sdk/core/index.ts +++ b/sdk/core/index.ts @@ -1,10 +1,7 @@ import { SelfBackendVerifier } from './src/SelfBackendVerifier.js'; import { countryCodes } from '@selfxyz/common/constants/constants'; -import { getUniversalLink, SelfAppBuilder } from '@selfxyz/common/utils/appType'; -export type { SelfApp } from '@selfxyz/common/utils/appType'; +import { getUniversalLink } from '@selfxyz/common/utils/appType'; import { countries } from '@selfxyz/common'; -import { hashEndpointWithScope } from '@selfxyz/common/utils/scope'; -import { getPackedForbiddenCountries } from '@selfxyz/common/utils/contracts/forbiddenCountries'; import type { AttestationId } from 'src/types/types.js'; import type { IConfigStorage } from 'src/store/interface.js'; import { DefaultConfigStore } from 'src/store/DefaultConfigStore.js'; @@ -14,9 +11,6 @@ export { countryCodes, getUniversalLink, countries, - hashEndpointWithScope, - SelfAppBuilder, - getPackedForbiddenCountries, AttestationId, IConfigStorage, DefaultConfigStore From 092a38ac4f6753508b8f2175a1160bbd0b3ba9e7 Mon Sep 17 00:00:00 2001 From: "coderabbitai[bot]" <136622811+coderabbitai[bot]@users.noreply.github.com> Date: Fri, 20 Jun 2025 21:48:44 +0530 Subject: [PATCH 12/25] =?UTF-8?q?=F0=9F=93=9D=20Add=20docstrings=20to=20`f?= =?UTF-8?q?ix/sdk`=20(#653)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Docstrings generation was requested by @remicolin. * https://github.com/selfxyz/self/pull/652#issuecomment-2992046545 The following files were modified: * `sdk/core/src/utils/hash.ts` * `sdk/core/src/utils/proof.ts` * `sdk/core/src/utils/utils.ts` Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> --- sdk/core/src/utils/hash.ts | 8 ++++++++ sdk/core/src/utils/proof.ts | 17 +++++++++++++++++ sdk/core/src/utils/utils.ts | 6 ++++++ 3 files changed, 31 insertions(+) diff --git a/sdk/core/src/utils/hash.ts b/sdk/core/src/utils/hash.ts index 237713332..71882dc9d 100644 --- a/sdk/core/src/utils/hash.ts +++ b/sdk/core/src/utils/hash.ts @@ -1,5 +1,13 @@ import { createHash } from "crypto"; +/** + * Generates a deterministic user identifier hash from the provided context data. + * + * The function computes a SHA-256 hash of the input buffer, then applies a RIPEMD-160 hash to the result. The final output is a hexadecimal string, left-padded with zeros to 40 characters and prefixed with "0x". + * + * @param userContextData - The buffer containing user context data to hash + * @returns A 40-character hexadecimal user identifier string prefixed with "0x" + */ export function calculateUserIdentifierHash(userContextData: Buffer): string { const sha256Hash = createHash("sha256") .update(userContextData) diff --git a/sdk/core/src/utils/proof.ts b/sdk/core/src/utils/proof.ts index be43104be..299d7e506 100644 --- a/sdk/core/src/utils/proof.ts +++ b/sdk/core/src/utils/proof.ts @@ -2,6 +2,14 @@ import { PublicSignals } from 'snarkjs'; import { discloseIndices } from './constants.js'; import { AttestationId } from 'src/types/types.js'; +/** + * Returns the number of public signals containing revealed data for the specified attestation ID. + * + * Throws an error if the attestation ID is not supported. + * + * @param attestationId - The attestation ID for which to determine the number of revealed data public signals + * @returns The number of public signals corresponding to revealed data + */ export function getRevealedDataPublicSignalsLength(attestationId: AttestationId): number { switch (attestationId) { case 1: @@ -18,6 +26,15 @@ export const bytesCount: Record = { 2: [31, 31, 31, 1], }; +/** + * Extracts and returns the revealed data bytes from the public signals for a given attestation ID. + * + * Iterates over the relevant public signals, unpacks each into its constituent bytes according to the attestation's byte structure, and accumulates all revealed bytes into a single array. + * + * @param attestationId - The attestation ID specifying the format of revealed data + * @param publicSignals - The array of public signals containing packed revealed data + * @returns An array of bytes representing the revealed data for the specified attestation + */ export function getRevealedDataBytes(attestationId: AttestationId, publicSignals: PublicSignals): number[] { let bytes: number[] = []; for (let i = 0; i < getRevealedDataPublicSignalsLength(attestationId); i++) { diff --git a/sdk/core/src/utils/utils.ts b/sdk/core/src/utils/utils.ts index cc948e588..8f91ba7ad 100644 --- a/sdk/core/src/utils/utils.ts +++ b/sdk/core/src/utils/utils.ts @@ -1,5 +1,11 @@ import { unpackReveal } from "@selfxyz/common/utils/circuits/formatOutputs"; +/** + * Unpacks a list of packed forbidden country codes into an array of 3-character country codes. + * + * @param forbiddenCountriesList_packed - An array of packed strings representing forbidden countries. + * @returns An array of 3-character country codes extracted from the packed input. + */ export function unpackForbiddenCountriesList(forbiddenCountriesList_packed: string[]) { const trimmed = unpackReveal(forbiddenCountriesList_packed, 'id'); const countries = []; From 320c47a92840cb21e8190a6beadaf835078e73c2 Mon Sep 17 00:00:00 2001 From: Ayman Date: Fri, 20 Jun 2025 21:51:44 +0530 Subject: [PATCH 13/25] review fixes --- common/package.json | 6 ++--- sdk/core/src/SelfBackendVerifier.ts | 12 ++++++---- yarn.lock | 35 +---------------------------- 3 files changed, 12 insertions(+), 41 deletions(-) diff --git a/common/package.json b/common/package.json index c7692fcea..75ec1ff18 100644 --- a/common/package.json +++ b/common/package.json @@ -9,17 +9,17 @@ ".": { "import": "./dist/esm/index.js", "require": "./dist/cjs/index.js", - "types": "./dist/esm/index.d.ts" + "types": "./dist/cjs/index.d.ts" }, "./constants/*": { "import": "./dist/esm/src/constants/*.js", "require": "./dist/cjs/src/constants/*.js", - "types": "./dist/esm/src/constants/*.d.ts" + "types": "./dist/cjs/src/constants/*.d.ts" }, "./utils/*": { "import": "./dist/esm/src/utils/*.js", "require": "./dist/cjs/src/utils/*.js", - "types": "./dist/esm/src/utils/*.d.ts" + "types": "./dist/cjs/src/utils/*.d.ts" }, "./ofacdata/outputs/nameAndDobSMT.json": "./ofacdata/outputs/nameAndDobSMT.json", "./ofacdata/outputs/nameAndYobSMT.json": "./ofacdata/outputs/nameAndYobSMT.json", diff --git a/sdk/core/src/SelfBackendVerifier.ts b/sdk/core/src/SelfBackendVerifier.ts index 8d1309ca0..f1c9b7222 100644 --- a/sdk/core/src/SelfBackendVerifier.ts +++ b/sdk/core/src/SelfBackendVerifier.ts @@ -93,8 +93,8 @@ export class SelfBackendVerifier { const verificationConfig = await this.configStorage.getConfig(configId); //check if forbidden countries list matches - const forbiddenCountriesList = unpackForbiddenCountriesList(verificationConfig.forbiddenCountriesListPacked.map(String)); - const forbiddenCountriesListVerificationConfig = unpackForbiddenCountriesList(verificationConfig.forbiddenCountriesListPacked.map(String)); + let forbiddenCountriesList: string[] = [0, 1, 2, 3].map((x) => publicSignals[discloseIndices[attestationId].forbiddenCountriesListPackedIndex + x]); + const forbiddenCountriesListVerificationConfig = unpackForbiddenCountriesList(verificationConfig.forbiddenCountriesListPacked); const isForbiddenCountryListValid = forbiddenCountriesListVerificationConfig.every(country => forbiddenCountriesList.includes(country as Country3LetterCode)); if (!isForbiddenCountryListValid) { @@ -115,7 +115,8 @@ export class SelfBackendVerifier { const currentTimestamp = new Date(); //check if timestamp is in the future - if (circuitTimestamp > currentTimestamp) { + const oneDayAgo = new Date(currentTimestamp.getTime() - (24 * 60 * 60 * 1000)); + if (circuitTimestamp > oneDayAgo) { issues.push({ type: ConfigMismatch.InvalidTimestamp, message: 'Circuit timestamp is in the future' }); } @@ -144,6 +145,9 @@ export class SelfBackendVerifier { let verifierContract: Verifier; try { const verifierAddress = await this.identityVerificationHubContract.discloseVerifier('0x' + attestationId.toString(16).padStart(64, '0')); + if (verifierAddress === '0x0000000000000000000000000000000000000000') { + throw new Error('Verifier contract not found'); + } verifierContract = Verifier__factory.connect(verifierAddress, this.provider); }catch (error) { throw new Error('Verifier contract not found'); @@ -160,7 +164,7 @@ export class SelfBackendVerifier { userIdentifier, userDefinedData, isOlderThanValid: verificationConfig.olderThanEnabled ? verificationConfig.olderThan <= genericDiscloseOutput.olderThan : true, - isForbiddenCountriesListValid: verificationConfig.forbiddenCountriesEnabled ? forbiddenCountriesList.includes(genericDiscloseOutput.nationality) : true, + isForbiddenCountriesListValid: verificationConfig.forbiddenCountriesEnabled ? !forbiddenCountriesList.includes(genericDiscloseOutput.nationality) : true, isOfacValid: verificationConfig.ofacEnabled.every((enabled, index) => enabled ? genericDiscloseOutput.ofac[index] : true), } } diff --git a/yarn.lock b/yarn.lock index 21dbc03a9..fb945154b 100644 --- a/yarn.lock +++ b/yarn.lock @@ -4308,39 +4308,6 @@ __metadata: languageName: unknown linkType: soft -"@selfxyz/common@file:../../common::locator=%40selfxyz%2Fcore%40workspace%3Asdk%2Fcore": - version: 0.0.2 - resolution: "@selfxyz/common@file:../../common#../../common::hash=c4cbd1&locator=%40selfxyz%2Fcore%40workspace%3Asdk%2Fcore" - dependencies: - "@openpassport/zk-kit-imt": "npm:^0.0.5" - "@openpassport/zk-kit-lean-imt": "npm:^0.0.6" - "@openpassport/zk-kit-smt": "npm:^0.0.1" - asn1.js: "npm:^5.4.1" - asn1js: "npm:^3.0.5" - axios: "npm:^1.7.2" - buffer: "npm:^6.0.3" - chai: "npm:^4.3.8" - country-emoji: "npm:^1.5.6" - country-iso-3-to-2: "npm:^1.1.1" - elliptic: "npm:^6.5.5" - fs: "npm:^0.0.1-security" - i18n-iso-countries: "npm:^7.13.0" - js-sha1: "npm:^0.7.0" - js-sha256: "npm:^0.11.0" - js-sha512: "npm:^0.9.0" - json-to-ts: "npm:^2.1.0" - jsrsasign: "npm:^11.1.0" - node-forge: "github:remicolin/forge#17a11a632dd0e50343b3b8393245a2696f78afbb" - path: "npm:^0.12.7" - pkijs: "npm:^3.2.4" - poseidon-lite: "npm:^0.2.0" - snarkjs: "npm:^0.7.5" - typescript-parser: "npm:^2.6.1" - uuid: "npm:^11.0.5" - checksum: 10c0/78ab1198944837f4726a467ccbe02133ce86ed5435980a997fe2c51f1c0261c48dfc03c5ddca23755060d7cd2df9d00d07f16dc14ad4bc2ec54ecf9966385aad - languageName: node - linkType: hard - "@selfxyz/common@workspace:, @selfxyz/common@workspace:^, @selfxyz/common@workspace:common": version: 0.0.0-use.local resolution: "@selfxyz/common@workspace:common" @@ -4436,7 +4403,7 @@ __metadata: version: 0.0.0-use.local resolution: "@selfxyz/core@workspace:sdk/core" dependencies: - "@selfxyz/common": "file:../../common" + "@selfxyz/common": "workspace:^" "@typechain/ethers-v6": "npm:^0.5.1" "@types/chai": "npm:^4.3.6" "@types/chai-as-promised": "npm:^7.1.8" From a812ee085c20e0bff1be77122975bb37583877ac Mon Sep 17 00:00:00 2001 From: Ayman Date: Fri, 20 Jun 2025 21:53:59 +0530 Subject: [PATCH 14/25] chore: fix package.json cjs types --- sdk/qrcode/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sdk/qrcode/package.json b/sdk/qrcode/package.json index 378922bb7..55b459789 100644 --- a/sdk/qrcode/package.json +++ b/sdk/qrcode/package.json @@ -15,7 +15,7 @@ "default": "./dist/index.js" }, "require": { - "types": "./dist/index.d.ts", + "types": "./dist/index.d.cts", "default": "./dist/index.cjs" } } From b73f6c8ee8e7f0d56cf56e60305edaff0a638fac Mon Sep 17 00:00:00 2001 From: Ayman Date: Fri, 20 Jun 2025 23:26:41 +0530 Subject: [PATCH 15/25] chore: add minor changes to checks --- sdk/core/src/SelfBackendVerifier.ts | 15 ++++++++------- sdk/core/src/utils/id.ts | 4 +++- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/sdk/core/src/SelfBackendVerifier.ts b/sdk/core/src/SelfBackendVerifier.ts index 9116c51f1..7a684e700 100644 --- a/sdk/core/src/SelfBackendVerifier.ts +++ b/sdk/core/src/SelfBackendVerifier.ts @@ -10,6 +10,7 @@ import { castToUserIdentifier, UserIdType } from '@selfxyz/common/utils/circuits import { ConfigMismatch, ConfigMismatchError } from './errors.js'; import { IConfigStorage } from './store/interface.js'; import { unpackForbiddenCountriesList } from './utils/utils.js'; +import { BigNumberish } from 'ethers'; const CELO_MAINNET_RPC_URL = 'https://forno.celo.org'; const CELO_TESTNET_RPC_URL = 'https://alfajores-forno.celo-testnet.org'; @@ -40,7 +41,7 @@ export class SelfBackendVerifier { public async verify( attestationId: AttestationId, proof: VcAndDiscloseProof, - pubSignals: string[], + pubSignals: BigNumberish[], userContextData: string, ) { //check if attestation id is allowed @@ -51,10 +52,9 @@ export class SelfBackendVerifier { } const publicSignals = pubSignals.map(String).map((x) => /[a-f]/g.test(x) ? '0x' + x : x); - //check if user context hash matches - const userContextHashInCircuit = publicSignals[discloseIndices[attestationId].userIdentifierIndex]; - const userContextHash = calculateUserIdentifierHash(Buffer.from(userContextData, "hex")); + const userContextHashInCircuit = BigInt(publicSignals[discloseIndices[attestationId].userIdentifierIndex]); + const userContextHash = BigInt(calculateUserIdentifierHash(Buffer.from(userContextData, "hex"))); if (userContextHashInCircuit !== userContextHash) { issues.push({ type: ConfigMismatch.InvalidUserContextHash, message: 'User context hash does not match with the one in the circuit' }); @@ -87,7 +87,7 @@ export class SelfBackendVerifier { issues.push({ type: ConfigMismatch.InvalidAttestationId, message: 'Attestation ID does not match with the one in the circuit' }); } - const userIdentifier = castToUserIdentifier(BigInt(userContextData.slice(64, 128)), this.userIdentifierType); + const userIdentifier = castToUserIdentifier(BigInt('0x' + userContextData.slice(64, 128)), this.userIdentifierType); const userDefinedData = userContextData.slice(128); const configId = await this.configStorage.getActionId(userIdentifier, userDefinedData); const verificationConfig = await this.configStorage.getConfig(configId); @@ -103,7 +103,7 @@ export class SelfBackendVerifier { const genericDiscloseOutput = formatRevealedDataPacked(attestationId, publicSignals); //check if minimum age matches - const isMinimumAgeValid = verificationConfig.olderThanEnabled ? verificationConfig.olderThan === genericDiscloseOutput.olderThan : true; + const isMinimumAgeValid = verificationConfig.olderThanEnabled ? verificationConfig.olderThan === genericDiscloseOutput.olderThan || genericDiscloseOutput.olderThan === '00' : true; if (!isMinimumAgeValid) { issues.push({ type: ConfigMismatch.InvalidMinimumAge, message: 'Minimum age in config does not match with the one in the circuit' }); } @@ -115,7 +115,7 @@ export class SelfBackendVerifier { const currentTimestamp = new Date(); //check if timestamp is in the future - const oneDayAgo = new Date(currentTimestamp.getTime() - (24 * 60 * 60 * 1000)); + const oneDayAgo = new Date(currentTimestamp.getTime() + (24 * 60 * 60 * 1000)); if (circuitTimestamp > oneDayAgo) { issues.push({ type: ConfigMismatch.InvalidTimestamp, message: 'Circuit timestamp is in the future' }); } @@ -153,6 +153,7 @@ export class SelfBackendVerifier { throw new Error('Verifier contract not found'); } + //TODO: put in try catch const isValid = await verifierContract.verifyProof(proof.a, [ [proof.b[0][1], proof.b[0][0]], [proof.b[1][1], proof.b[1][0]], diff --git a/sdk/core/src/utils/id.ts b/sdk/core/src/utils/id.ts index 1e4b13fc7..f10f7313c 100644 --- a/sdk/core/src/utils/id.ts +++ b/sdk/core/src/utils/id.ts @@ -6,6 +6,7 @@ export const formatRevealedDataPacked = (attestationId: AttestationId, publicSig const revealedDataPacked = getRevealedDataBytes(attestationId, publicSignals); const revealedDataPackedString = Buffer.from(revealedDataPacked); + const nullifier = publicSignals[discloseIndices[attestationId].nullifierIndex]; const forbiddenCountriesListPacked = publicSignals.slice(discloseIndices[attestationId].forbiddenCountriesListPackedIndex, discloseIndices[attestationId].forbiddenCountriesListPackedIndex + 3); const issuingState = revealedDataPackedString.subarray(revealedDataIndices[attestationId].issuingStateStart, revealedDataIndices[attestationId].issuingStateEnd + 1).toString("utf-8"); @@ -15,8 +16,9 @@ export const formatRevealedDataPacked = (attestationId: AttestationId, publicSig const dateOfBirth = revealedDataPackedString.subarray(revealedDataIndices[attestationId].dateOfBirthStart, revealedDataIndices[attestationId].dateOfBirthEnd + 1).toString("utf-8"); const gender = revealedDataPackedString.subarray(revealedDataIndices[attestationId].genderStart, revealedDataIndices[attestationId].genderEnd + 1).toString("utf-8"); const expiryDate = revealedDataPackedString.subarray(revealedDataIndices[attestationId].expiryDateStart, revealedDataIndices[attestationId].expiryDateEnd + 1).toString("utf-8"); - const olderThan = revealedDataPackedString.subarray(revealedDataIndices[attestationId].olderThanStart, revealedDataIndices[attestationId].olderThanEnd + 1).toString("utf-8"); + const olderThan = Buffer.from(revealedDataPackedString.subarray(revealedDataIndices[attestationId].olderThanStart, revealedDataIndices[attestationId].olderThanEnd + 1).map((x) => x + 48)).toString("utf-8"); const ofac = Array.from(revealedDataPackedString.subarray(revealedDataIndices[attestationId].ofacStart, revealedDataIndices[attestationId].ofacEnd + 1)).map(Boolean); + console.log("ofac",ofac); return { nullifier: nullifier.toString(), From bf60c292c88d0eaa5694315015618241d2c4b4eb Mon Sep 17 00:00:00 2001 From: Ayman Date: Sat, 21 Jun 2025 17:41:58 +0530 Subject: [PATCH 16/25] feat: add InMemoryConfigStore, allIds constant and verificationResult type --- sdk/core/index.ts | 9 +++++-- sdk/core/src/SelfBackendVerifier.ts | 31 +++++++++++++++++------ sdk/core/src/errors.ts | 3 ++- sdk/core/src/store/InMemoryConfigStore.ts | 25 ++++++++++++++++++ sdk/core/src/store/interface.ts | 2 +- sdk/core/src/types/types.ts | 15 +++++++++++ sdk/core/src/utils/constants.ts | 3 +++ 7 files changed, 76 insertions(+), 12 deletions(-) create mode 100644 sdk/core/src/store/InMemoryConfigStore.ts diff --git a/sdk/core/index.ts b/sdk/core/index.ts index bc8009b66..6c65cf043 100644 --- a/sdk/core/index.ts +++ b/sdk/core/index.ts @@ -2,9 +2,11 @@ import { SelfBackendVerifier } from './src/SelfBackendVerifier.js'; import { countryCodes } from '@selfxyz/common/constants/constants'; import { getUniversalLink } from '@selfxyz/common/utils/appType'; import { countries } from '@selfxyz/common'; -import type { AttestationId } from 'src/types/types.js'; +import type { AttestationId, VerificationResult } from 'src/types/types.js'; import type { IConfigStorage } from 'src/store/interface.js'; import { DefaultConfigStore } from 'src/store/DefaultConfigStore.js'; +import { AllIds } from 'src/utils/constants.js'; +import { InMemoryConfigStore } from 'src/store/InMemoryConfigStore.js'; export { SelfBackendVerifier, @@ -13,5 +15,8 @@ export { countries, AttestationId, IConfigStorage, - DefaultConfigStore + DefaultConfigStore, + InMemoryConfigStore, + AllIds, + VerificationResult, }; diff --git a/sdk/core/src/SelfBackendVerifier.ts b/sdk/core/src/SelfBackendVerifier.ts index 7a684e700..e1335a4f3 100644 --- a/sdk/core/src/SelfBackendVerifier.ts +++ b/sdk/core/src/SelfBackendVerifier.ts @@ -90,7 +90,12 @@ export class SelfBackendVerifier { const userIdentifier = castToUserIdentifier(BigInt('0x' + userContextData.slice(64, 128)), this.userIdentifierType); const userDefinedData = userContextData.slice(128); const configId = await this.configStorage.getActionId(userIdentifier, userDefinedData); - const verificationConfig = await this.configStorage.getConfig(configId); + let verificationConfig; + try { + verificationConfig = await this.configStorage.getConfig(configId); + } catch (error) { + issues.push({ type: ConfigMismatch.ConfigNotFound, message: 'Config not found' }); + } //check if forbidden countries list matches let forbiddenCountriesList: string[] = [0, 1, 2, 3].map((x) => publicSignals[discloseIndices[attestationId].forbiddenCountriesListPackedIndex + x]); @@ -153,19 +158,29 @@ export class SelfBackendVerifier { throw new Error('Verifier contract not found'); } - //TODO: put in try catch - const isValid = await verifierContract.verifyProof(proof.a, [ + let isValid = false; + try { + isValid = await verifierContract.verifyProof(proof.a, [ [proof.b[0][1], proof.b[0][0]], [proof.b[1][1], proof.b[1][0]], ], proof.c, publicSignals); + } catch (error) { + isValid = false; + } return { - isValid, + attestationId, + isValidDetails: { + isValid, + isOlderThanValid: verificationConfig.olderThanEnabled ? verificationConfig.olderThan <= genericDiscloseOutput.olderThan : true, + isOfacValid: verificationConfig.ofacEnabled.every((enabled: boolean, index: number) => enabled ? genericDiscloseOutput.ofac[index] : true), + }, + forbiddenCountriesList, discloseOutput: genericDiscloseOutput, - userIdentifier, - userDefinedData, - isOlderThanValid: verificationConfig.olderThanEnabled ? verificationConfig.olderThan <= genericDiscloseOutput.olderThan : true, - isOfacValid: verificationConfig.ofacEnabled.every((enabled, index) => enabled ? genericDiscloseOutput.ofac[index] : true), + userData: { + userIdentifier, + userDefinedData, + }, } } } diff --git a/sdk/core/src/errors.ts b/sdk/core/src/errors.ts index 11e1118ac..fd701e11e 100644 --- a/sdk/core/src/errors.ts +++ b/sdk/core/src/errors.ts @@ -7,7 +7,8 @@ export enum ConfigMismatch { InvalidForbiddenCountriesList = 'InvalidForbiddenCountriesList', InvalidMinimumAge = 'InvalidMinimumAge', InvalidTimestamp = 'InvalidTimestamp', - InvalidOfac = 'InvalidOfac' + InvalidOfac = 'InvalidOfac', + ConfigNotFound = 'ConfigNotFound' } export class ConfigMismatchError extends Error { diff --git a/sdk/core/src/store/InMemoryConfigStore.ts b/sdk/core/src/store/InMemoryConfigStore.ts new file mode 100644 index 000000000..7e99f67b3 --- /dev/null +++ b/sdk/core/src/store/InMemoryConfigStore.ts @@ -0,0 +1,25 @@ +import { VerificationConfig } from "src/types/types.js"; +import { IConfigStorage } from "./interface.js"; + +export class InMemoryConfigStore implements IConfigStorage { + private configs: Map = new Map(); + private getActionIdFunc: IConfigStorage['getActionId']; + + constructor(getActionIdFunc: IConfigStorage['getActionId']) { + this.getActionIdFunc = getActionIdFunc; + } + + async getActionId(userIdentifier: string, userDefinedData: string): Promise { + return this.getActionIdFunc(userIdentifier, userDefinedData); + } + + async setConfig(configId: string, config: VerificationConfig): Promise { + const existed = this.configs.has(configId); + this.configs.set(configId, config); + return !existed; + } + + async getConfig(configId: string): Promise { + return this.configs.get(configId); + } +} diff --git a/sdk/core/src/store/interface.ts b/sdk/core/src/store/interface.ts index 545133614..031cd83f5 100644 --- a/sdk/core/src/store/interface.ts +++ b/sdk/core/src/store/interface.ts @@ -11,7 +11,7 @@ export interface IConfigStorage { * Set the verification config for a given id * @param id - An identifiier associated with the verification config * @param config - The verification config - * @returns True if the config was set successfully, false otherwise + * @returns True if a config was replaced, false if a new config was set */ setConfig(id: string, config: VerificationConfig): Promise; /** diff --git a/sdk/core/src/types/types.ts b/sdk/core/src/types/types.ts index c7e4cbe73..d4dad9fbd 100644 --- a/sdk/core/src/types/types.ts +++ b/sdk/core/src/types/types.ts @@ -15,6 +15,21 @@ export type VerificationConfig = { ofacEnabled: [boolean, boolean, boolean]; }; +export type VerificationResult = { + attestationId: AttestationId; + isValidDetails: { + isValid: boolean; + isOlderThanValid: boolean; + isOfacValid: boolean; + }; + forbiddenCountriesList: string[]; + discloseOutput: GenericDiscloseOutput; + userData: { + userIdentifier: string; + userDefinedData: string; + }; +} + export type GenericDiscloseOutput = { nullifier: string; forbiddenCountriesListPacked: string[]; diff --git a/sdk/core/src/utils/constants.ts b/sdk/core/src/utils/constants.ts index cd89947a6..9c3303893 100644 --- a/sdk/core/src/utils/constants.ts +++ b/sdk/core/src/utils/constants.ts @@ -73,3 +73,6 @@ export const revealedDataIndices: Record [Number(id), true] as [number, boolean]); +export const AllIds = new Map(allIdEntries); From a73762b649f1449cc807871dbf832d9d73da6e51 Mon Sep 17 00:00:00 2001 From: Ayman Date: Sat, 21 Jun 2025 18:42:56 +0530 Subject: [PATCH 17/25] chore: export Verification config --- sdk/core/index.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/sdk/core/index.ts b/sdk/core/index.ts index 6c65cf043..c825a0645 100644 --- a/sdk/core/index.ts +++ b/sdk/core/index.ts @@ -2,7 +2,7 @@ import { SelfBackendVerifier } from './src/SelfBackendVerifier.js'; import { countryCodes } from '@selfxyz/common/constants/constants'; import { getUniversalLink } from '@selfxyz/common/utils/appType'; import { countries } from '@selfxyz/common'; -import type { AttestationId, VerificationResult } from 'src/types/types.js'; +import type { AttestationId, VerificationResult, VerificationConfig } from 'src/types/types.js'; import type { IConfigStorage } from 'src/store/interface.js'; import { DefaultConfigStore } from 'src/store/DefaultConfigStore.js'; import { AllIds } from 'src/utils/constants.js'; @@ -19,4 +19,5 @@ export { InMemoryConfigStore, AllIds, VerificationResult, + VerificationConfig, }; From 4dfbdeef50df4b0b413d9aeaa326602d01f19dce Mon Sep 17 00:00:00 2001 From: Ayman Date: Sat, 21 Jun 2025 19:05:27 +0530 Subject: [PATCH 18/25] feat: change the verification config types --- sdk/core/src/SelfBackendVerifier.ts | 28 ++++++++++++++-------------- sdk/core/src/types/types.ts | 9 ++++----- 2 files changed, 18 insertions(+), 19 deletions(-) diff --git a/sdk/core/src/SelfBackendVerifier.ts b/sdk/core/src/SelfBackendVerifier.ts index e1335a4f3..5b002cc27 100644 --- a/sdk/core/src/SelfBackendVerifier.ts +++ b/sdk/core/src/SelfBackendVerifier.ts @@ -3,7 +3,7 @@ import { hashEndpointWithScope } from '@selfxyz/common/utils/scope'; import { IdentityVerificationHubImpl, IdentityVerificationHubImpl__factory, Registry__factory, Verifier, Verifier__factory } from './typechain-types/index.js'; import { discloseIndices } from './utils/constants.js'; import { formatRevealedDataPacked } from './utils/id.js'; -import { AttestationId, VcAndDiscloseProof } from './types/types.js'; +import { AttestationId, VcAndDiscloseProof, VerificationConfig } from './types/types.js'; import { Country3LetterCode } from '@selfxyz/common'; import { calculateUserIdentifierHash } from './utils/hash.js'; import { castToUserIdentifier, UserIdType } from '@selfxyz/common/utils/circuits/uuid'; @@ -90,7 +90,7 @@ export class SelfBackendVerifier { const userIdentifier = castToUserIdentifier(BigInt('0x' + userContextData.slice(64, 128)), this.userIdentifierType); const userDefinedData = userContextData.slice(128); const configId = await this.configStorage.getActionId(userIdentifier, userDefinedData); - let verificationConfig; + let verificationConfig: VerificationConfig; try { verificationConfig = await this.configStorage.getConfig(configId); } catch (error) { @@ -98,8 +98,8 @@ export class SelfBackendVerifier { } //check if forbidden countries list matches - let forbiddenCountriesList: string[] = [0, 1, 2, 3].map((x) => publicSignals[discloseIndices[attestationId].forbiddenCountriesListPackedIndex + x]); - const forbiddenCountriesListVerificationConfig = unpackForbiddenCountriesList(verificationConfig.forbiddenCountriesListPacked); + const forbiddenCountriesList: string[] = unpackForbiddenCountriesList([0, 1, 2, 3].map((x) => publicSignals[discloseIndices[attestationId].forbiddenCountriesListPackedIndex + x])); + const forbiddenCountriesListVerificationConfig = verificationConfig.forbiddenCountriesList; const isForbiddenCountryListValid = forbiddenCountriesListVerificationConfig.every(country => forbiddenCountriesList.includes(country as Country3LetterCode)); if (!isForbiddenCountryListValid) { @@ -108,7 +108,7 @@ export class SelfBackendVerifier { const genericDiscloseOutput = formatRevealedDataPacked(attestationId, publicSignals); //check if minimum age matches - const isMinimumAgeValid = verificationConfig.olderThanEnabled ? verificationConfig.olderThan === genericDiscloseOutput.olderThan || genericDiscloseOutput.olderThan === '00' : true; + const isMinimumAgeValid = verificationConfig.olderThan !== undefined ? verificationConfig.olderThan === Number.parseInt(genericDiscloseOutput.olderThan, 10) || genericDiscloseOutput.olderThan === '00' : true; if (!isMinimumAgeValid) { issues.push({ type: ConfigMismatch.InvalidMinimumAge, message: 'Minimum age in config does not match with the one in the circuit' }); } @@ -120,26 +120,26 @@ export class SelfBackendVerifier { const currentTimestamp = new Date(); //check if timestamp is in the future - const oneDayAgo = new Date(currentTimestamp.getTime() + (24 * 60 * 60 * 1000)); - if (circuitTimestamp > oneDayAgo) { + const oneDayAhead = new Date(currentTimestamp.getTime() + (24 * 60 * 60 * 1000)); + if (circuitTimestamp > oneDayAhead) { issues.push({ type: ConfigMismatch.InvalidTimestamp, message: 'Circuit timestamp is in the future' }); } //check if timestamp is 1 day in the past - currentTimestamp.setTime(currentTimestamp.getTime() - (24 * 60 * 60 * 1000)); - if (circuitTimestamp < currentTimestamp) { + const oneDayAgo = new Date(currentTimestamp.getTime() - (24 * 60 * 60 * 1000)); + if (circuitTimestamp < oneDayAgo) { issues.push({ type: ConfigMismatch.InvalidTimestamp, message: 'Circuit timestamp is too old' }); } - if (!verificationConfig.ofacEnabled[0] && genericDiscloseOutput.ofac[0]) { + if (!verificationConfig.ofac && genericDiscloseOutput.ofac[0]) { issues.push({ type: ConfigMismatch.InvalidOfac, message: 'Passport number OFAC check is not allowed' }); } - if (!verificationConfig.ofacEnabled[1] && genericDiscloseOutput.ofac[1]) { + if (!verificationConfig.ofac && genericDiscloseOutput.ofac[1]) { issues.push({ type: ConfigMismatch.InvalidOfac, message: 'Name and DOB OFAC check is not allowed' }); } - if (!verificationConfig.ofacEnabled[2] && genericDiscloseOutput.ofac[2]) { + if (!verificationConfig.ofac && genericDiscloseOutput.ofac[2]) { issues.push({ type: ConfigMismatch.InvalidOfac, message: 'Name and YOB OFAC check is not allowed' }); } @@ -172,8 +172,8 @@ export class SelfBackendVerifier { attestationId, isValidDetails: { isValid, - isOlderThanValid: verificationConfig.olderThanEnabled ? verificationConfig.olderThan <= genericDiscloseOutput.olderThan : true, - isOfacValid: verificationConfig.ofacEnabled.every((enabled: boolean, index: number) => enabled ? genericDiscloseOutput.ofac[index] : true), + isOlderThanValid: verificationConfig.olderThan !== undefined ? verificationConfig.olderThan <= Number.parseInt(genericDiscloseOutput.olderThan, 10) : true, + isOfacValid: verificationConfig.ofac !== undefined && verificationConfig.ofac ? genericDiscloseOutput.ofac.every((enabled: boolean, index: number) => enabled ? genericDiscloseOutput.ofac[index] : true) : true, }, forbiddenCountriesList, discloseOutput: genericDiscloseOutput, diff --git a/sdk/core/src/types/types.ts b/sdk/core/src/types/types.ts index d4dad9fbd..4eaa6aab3 100644 --- a/sdk/core/src/types/types.ts +++ b/sdk/core/src/types/types.ts @@ -1,3 +1,4 @@ +import { Country3LetterCode } from '@selfxyz/common'; import type { BigNumberish } from 'ethers'; import { discloseIndices } from 'src/utils/constants.js'; @@ -8,11 +9,9 @@ export type VcAndDiscloseProof = { }; export type VerificationConfig = { - olderThanEnabled: boolean; - olderThan: string; - forbiddenCountriesEnabled: boolean; - forbiddenCountriesListPacked: string[]; - ofacEnabled: [boolean, boolean, boolean]; + olderThan?: number; + forbiddenCountriesList?: Country3LetterCode[]; + ofac?: boolean; }; export type VerificationResult = { From 01bc85eb6cb09f683d7f07654fa4d33533a8198d Mon Sep 17 00:00:00 2001 From: Ayman Date: Mon, 23 Jun 2025 15:05:01 +0530 Subject: [PATCH 19/25] fix: throw issues early if verification config is null --- sdk/core/src/SelfBackendVerifier.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/sdk/core/src/SelfBackendVerifier.ts b/sdk/core/src/SelfBackendVerifier.ts index 5b002cc27..471a863ce 100644 --- a/sdk/core/src/SelfBackendVerifier.ts +++ b/sdk/core/src/SelfBackendVerifier.ts @@ -90,11 +90,13 @@ export class SelfBackendVerifier { const userIdentifier = castToUserIdentifier(BigInt('0x' + userContextData.slice(64, 128)), this.userIdentifierType); const userDefinedData = userContextData.slice(128); const configId = await this.configStorage.getActionId(userIdentifier, userDefinedData); - let verificationConfig: VerificationConfig; + let verificationConfig: VerificationConfig | null; try { verificationConfig = await this.configStorage.getConfig(configId); } catch (error) { issues.push({ type: ConfigMismatch.ConfigNotFound, message: 'Config not found' }); + } finally { + if (!verificationConfig) throw new ConfigMismatchError(issues); } //check if forbidden countries list matches From 5494382cd0b8ce21b66a2798ce5b65031e2bf161 Mon Sep 17 00:00:00 2001 From: Ayman Date: Mon, 23 Jun 2025 15:17:43 +0530 Subject: [PATCH 20/25] fix: update yarn.lock file --- yarn.lock | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/yarn.lock b/yarn.lock index 5577aed91..f85b88aa5 100644 --- a/yarn.lock +++ b/yarn.lock @@ -19524,9 +19524,9 @@ __metadata: languageName: node linkType: hard -"react-native-gesture-handler@npm:^2.22.1": - version: 2.26.0 - resolution: "react-native-gesture-handler@npm:2.26.0" +"react-native-gesture-handler@npm:2.24.0": + version: 2.24.0 + resolution: "react-native-gesture-handler@npm:2.24.0" dependencies: "@egjs/hammerjs": "npm:^2.0.17" hoist-non-react-statics: "npm:^3.3.0" @@ -19534,7 +19534,7 @@ __metadata: peerDependencies: react: "*" react-native: "*" - checksum: 10c0/43aee4f0aeb7be9e2e72a9abaeaff38104c188a44ffc1a5634940a851adca5f10ee3a8d1b4828eb654574d4d45aa0f0c2af5a7b4ed2e9bca4e76d0d932f13955 + checksum: 10c0/eb2c5cb53690ae5de1482370a156cbd775f6b3054540cd47310ec4712df83a280fe7b6259f372eec4c14a6d7f70ab18f1919a9fe63beaca9ceae126edbe32298 languageName: node linkType: hard From ee63e9c4d0ebf1afd56baed77ae488be4405da0c Mon Sep 17 00:00:00 2001 From: Ayman Date: Mon, 23 Jun 2025 15:21:31 +0530 Subject: [PATCH 21/25] chore: lint --- sdk/core/src/SelfBackendVerifier.ts | 185 +++++++++++++++++----- sdk/core/src/errors.ts | 4 +- sdk/core/src/store/DefaultConfigStore.ts | 6 +- sdk/core/src/store/InMemoryConfigStore.ts | 4 +- sdk/core/src/store/interface.ts | 2 +- sdk/core/src/types/types.ts | 4 +- sdk/core/src/utils/constants.ts | 26 ++- sdk/core/src/utils/hash.ts | 10 +- sdk/core/src/utils/id.ts | 88 ++++++++-- sdk/core/src/utils/proof.ts | 9 +- sdk/core/src/utils/utils.ts | 2 +- sdk/qrcode/tsup.config.ts | 2 +- 12 files changed, 258 insertions(+), 84 deletions(-) diff --git a/sdk/core/src/SelfBackendVerifier.ts b/sdk/core/src/SelfBackendVerifier.ts index 471a863ce..4163f4fcd 100644 --- a/sdk/core/src/SelfBackendVerifier.ts +++ b/sdk/core/src/SelfBackendVerifier.ts @@ -1,6 +1,12 @@ import { ethers } from 'ethers'; import { hashEndpointWithScope } from '@selfxyz/common/utils/scope'; -import { IdentityVerificationHubImpl, IdentityVerificationHubImpl__factory, Registry__factory, Verifier, Verifier__factory } from './typechain-types/index.js'; +import { + IdentityVerificationHubImpl, + IdentityVerificationHubImpl__factory, + Registry__factory, + Verifier, + Verifier__factory, +} from './typechain-types/index.js'; import { discloseIndices } from './utils/constants.js'; import { formatRevealedDataPacked } from './utils/id.js'; import { AttestationId, VcAndDiscloseProof, VerificationConfig } from './types/types.js'; @@ -26,11 +32,23 @@ export class SelfBackendVerifier { protected allowedIds: Map; protected userIdentifierType: UserIdType; - constructor(scope: string, endpoint: string, mockPassport: boolean = false, allowedIds: Map, configStorage: IConfigStorage, userIdentifierType: UserIdType) { + constructor( + scope: string, + endpoint: string, + mockPassport: boolean = false, + allowedIds: Map, + configStorage: IConfigStorage, + userIdentifierType: UserIdType + ) { const rpcUrl = mockPassport ? CELO_TESTNET_RPC_URL : CELO_MAINNET_RPC_URL; const provider = new ethers.JsonRpcProvider(rpcUrl); - const identityVerificationHubAddress = mockPassport ? IDENTITY_VERIFICATION_HUB_ADDRESS_STAGING : IDENTITY_VERIFICATION_HUB_ADDRESS; - this.identityVerificationHubContract = IdentityVerificationHubImpl__factory.connect(identityVerificationHubAddress, provider); + const identityVerificationHubAddress = mockPassport + ? IDENTITY_VERIFICATION_HUB_ADDRESS_STAGING + : IDENTITY_VERIFICATION_HUB_ADDRESS; + this.identityVerificationHubContract = IdentityVerificationHubImpl__factory.connect( + identityVerificationHubAddress, + provider + ); this.provider = provider; this.scope = hashEndpointWithScope(endpoint, scope); this.allowedIds = allowedIds; @@ -42,7 +60,7 @@ export class SelfBackendVerifier { attestationId: AttestationId, proof: VcAndDiscloseProof, pubSignals: BigNumberish[], - userContextData: string, + userContextData: string ) { //check if attestation id is allowed const allowedId = this.allowedIds.get(attestationId); @@ -51,43 +69,67 @@ export class SelfBackendVerifier { issues.push({ type: ConfigMismatch.InvalidId, message: 'Attestation ID is not allowed' }); } - const publicSignals = pubSignals.map(String).map((x) => /[a-f]/g.test(x) ? '0x' + x : x); + const publicSignals = pubSignals.map(String).map((x) => (/[a-f]/g.test(x) ? '0x' + x : x)); //check if user context hash matches - const userContextHashInCircuit = BigInt(publicSignals[discloseIndices[attestationId].userIdentifierIndex]); - const userContextHash = BigInt(calculateUserIdentifierHash(Buffer.from(userContextData, "hex"))); + const userContextHashInCircuit = BigInt( + publicSignals[discloseIndices[attestationId].userIdentifierIndex] + ); + const userContextHash = BigInt( + calculateUserIdentifierHash(Buffer.from(userContextData, 'hex')) + ); if (userContextHashInCircuit !== userContextHash) { - issues.push({ type: ConfigMismatch.InvalidUserContextHash, message: 'User context hash does not match with the one in the circuit' }); + issues.push({ + type: ConfigMismatch.InvalidUserContextHash, + message: 'User context hash does not match with the one in the circuit', + }); } //check if scope matches const isValidScope = this.scope === publicSignals[discloseIndices[attestationId].scopeIndex]; if (!isValidScope) { - issues.push({ type: ConfigMismatch.InvalidScope, message: 'Scope does not match with the one in the circuit' }); + issues.push({ + type: ConfigMismatch.InvalidScope, + message: 'Scope does not match with the one in the circuit', + }); } //check the root try { - const registryAddress = await this.identityVerificationHubContract.registry('0x' + attestationId.toString(16).padStart(64, '0')); + const registryAddress = await this.identityVerificationHubContract.registry( + '0x' + attestationId.toString(16).padStart(64, '0') + ); if (registryAddress === '0x0000000000000000000000000000000000000000') { throw new Error('Registry contract not found'); } const registryContract = Registry__factory.connect(registryAddress, this.provider); - const currentRoot = await registryContract.checkIdentityCommitmentRoot(publicSignals[discloseIndices[attestationId].merkleRootIndex]); + const currentRoot = await registryContract.checkIdentityCommitmentRoot( + publicSignals[discloseIndices[attestationId].merkleRootIndex] + ); if (!currentRoot) { - issues.push({ type: ConfigMismatch.InvalidRoot, message: 'Onchain root does not match with the one in the circuit' }); + issues.push({ + type: ConfigMismatch.InvalidRoot, + message: 'Onchain root does not match with the one in the circuit', + }); } } catch (error) { throw new Error('Registry contract not found'); } //check if attestation id matches - const isValidAttestationId = attestationId.toString() === publicSignals[discloseIndices[attestationId].attestationIdIndex]; + const isValidAttestationId = + attestationId.toString() === publicSignals[discloseIndices[attestationId].attestationIdIndex]; if (!isValidAttestationId) { - issues.push({ type: ConfigMismatch.InvalidAttestationId, message: 'Attestation ID does not match with the one in the circuit' }); + issues.push({ + type: ConfigMismatch.InvalidAttestationId, + message: 'Attestation ID does not match with the one in the circuit', + }); } - const userIdentifier = castToUserIdentifier(BigInt('0x' + userContextData.slice(64, 128)), this.userIdentifierType); + const userIdentifier = castToUserIdentifier( + BigInt('0x' + userContextData.slice(64, 128)), + this.userIdentifierType + ); const userDefinedData = userContextData.slice(128); const configId = await this.configStorage.getActionId(userIdentifier, userDefinedData); let verificationConfig: VerificationConfig | null; @@ -100,49 +142,95 @@ export class SelfBackendVerifier { } //check if forbidden countries list matches - const forbiddenCountriesList: string[] = unpackForbiddenCountriesList([0, 1, 2, 3].map((x) => publicSignals[discloseIndices[attestationId].forbiddenCountriesListPackedIndex + x])); + const forbiddenCountriesList: string[] = unpackForbiddenCountriesList( + [0, 1, 2, 3].map( + (x) => publicSignals[discloseIndices[attestationId].forbiddenCountriesListPackedIndex + x] + ) + ); const forbiddenCountriesListVerificationConfig = verificationConfig.forbiddenCountriesList; - const isForbiddenCountryListValid = forbiddenCountriesListVerificationConfig.every(country => forbiddenCountriesList.includes(country as Country3LetterCode)); + const isForbiddenCountryListValid = forbiddenCountriesListVerificationConfig.every((country) => + forbiddenCountriesList.includes(country as Country3LetterCode) + ); if (!isForbiddenCountryListValid) { - issues.push({ type: ConfigMismatch.InvalidForbiddenCountriesList, message: 'Forbidden countries list in config does not match with the one in the circuit' }); + issues.push({ + type: ConfigMismatch.InvalidForbiddenCountriesList, + message: 'Forbidden countries list in config does not match with the one in the circuit', + }); } const genericDiscloseOutput = formatRevealedDataPacked(attestationId, publicSignals); //check if minimum age matches - const isMinimumAgeValid = verificationConfig.olderThan !== undefined ? verificationConfig.olderThan === Number.parseInt(genericDiscloseOutput.olderThan, 10) || genericDiscloseOutput.olderThan === '00' : true; + const isMinimumAgeValid = + verificationConfig.olderThan !== undefined + ? verificationConfig.olderThan === Number.parseInt(genericDiscloseOutput.olderThan, 10) || + genericDiscloseOutput.olderThan === '00' + : true; if (!isMinimumAgeValid) { - issues.push({ type: ConfigMismatch.InvalidMinimumAge, message: 'Minimum age in config does not match with the one in the circuit' }); + issues.push({ + type: ConfigMismatch.InvalidMinimumAge, + message: 'Minimum age in config does not match with the one in the circuit', + }); } - const circuitTimestampYy = [2, 0, publicSignals[discloseIndices[attestationId].currentDateIndex], publicSignals[discloseIndices[attestationId].currentDateIndex + 1]]; - const circuitTimestampMm = [publicSignals[discloseIndices[attestationId].currentDateIndex + 2], publicSignals[discloseIndices[attestationId].currentDateIndex + 3]]; - const circuitTimestampDd = [publicSignals[discloseIndices[attestationId].currentDateIndex + 4], publicSignals[discloseIndices[attestationId].currentDateIndex + 5]]; - const circuitTimestamp = new Date(Number(circuitTimestampYy.join('')), Number(circuitTimestampMm.join('')) - 1, Number(circuitTimestampDd.join(''))); + const circuitTimestampYy = [ + 2, + 0, + publicSignals[discloseIndices[attestationId].currentDateIndex], + publicSignals[discloseIndices[attestationId].currentDateIndex + 1], + ]; + const circuitTimestampMm = [ + publicSignals[discloseIndices[attestationId].currentDateIndex + 2], + publicSignals[discloseIndices[attestationId].currentDateIndex + 3], + ]; + const circuitTimestampDd = [ + publicSignals[discloseIndices[attestationId].currentDateIndex + 4], + publicSignals[discloseIndices[attestationId].currentDateIndex + 5], + ]; + const circuitTimestamp = new Date( + Number(circuitTimestampYy.join('')), + Number(circuitTimestampMm.join('')) - 1, + Number(circuitTimestampDd.join('')) + ); const currentTimestamp = new Date(); //check if timestamp is in the future - const oneDayAhead = new Date(currentTimestamp.getTime() + (24 * 60 * 60 * 1000)); + const oneDayAhead = new Date(currentTimestamp.getTime() + 24 * 60 * 60 * 1000); if (circuitTimestamp > oneDayAhead) { - issues.push({ type: ConfigMismatch.InvalidTimestamp, message: 'Circuit timestamp is in the future' }); + issues.push({ + type: ConfigMismatch.InvalidTimestamp, + message: 'Circuit timestamp is in the future', + }); } //check if timestamp is 1 day in the past - const oneDayAgo = new Date(currentTimestamp.getTime() - (24 * 60 * 60 * 1000)); + const oneDayAgo = new Date(currentTimestamp.getTime() - 24 * 60 * 60 * 1000); if (circuitTimestamp < oneDayAgo) { - issues.push({ type: ConfigMismatch.InvalidTimestamp, message: 'Circuit timestamp is too old' }); + issues.push({ + type: ConfigMismatch.InvalidTimestamp, + message: 'Circuit timestamp is too old', + }); } if (!verificationConfig.ofac && genericDiscloseOutput.ofac[0]) { - issues.push({ type: ConfigMismatch.InvalidOfac, message: 'Passport number OFAC check is not allowed' }); + issues.push({ + type: ConfigMismatch.InvalidOfac, + message: 'Passport number OFAC check is not allowed', + }); } if (!verificationConfig.ofac && genericDiscloseOutput.ofac[1]) { - issues.push({ type: ConfigMismatch.InvalidOfac, message: 'Name and DOB OFAC check is not allowed' }); + issues.push({ + type: ConfigMismatch.InvalidOfac, + message: 'Name and DOB OFAC check is not allowed', + }); } if (!verificationConfig.ofac && genericDiscloseOutput.ofac[2]) { - issues.push({ type: ConfigMismatch.InvalidOfac, message: 'Name and YOB OFAC check is not allowed' }); + issues.push({ + type: ConfigMismatch.InvalidOfac, + message: 'Name and YOB OFAC check is not allowed', + }); } if (issues.length > 0) { @@ -151,21 +239,28 @@ export class SelfBackendVerifier { let verifierContract: Verifier; try { - const verifierAddress = await this.identityVerificationHubContract.discloseVerifier('0x' + attestationId.toString(16).padStart(64, '0')); + const verifierAddress = await this.identityVerificationHubContract.discloseVerifier( + '0x' + attestationId.toString(16).padStart(64, '0') + ); if (verifierAddress === '0x0000000000000000000000000000000000000000') { throw new Error('Verifier contract not found'); } verifierContract = Verifier__factory.connect(verifierAddress, this.provider); - }catch (error) { + } catch (error) { throw new Error('Verifier contract not found'); } let isValid = false; try { - isValid = await verifierContract.verifyProof(proof.a, [ - [proof.b[0][1], proof.b[0][0]], - [proof.b[1][1], proof.b[1][0]], - ], proof.c, publicSignals); + isValid = await verifierContract.verifyProof( + proof.a, + [ + [proof.b[0][1], proof.b[0][0]], + [proof.b[1][1], proof.b[1][0]], + ], + proof.c, + publicSignals + ); } catch (error) { isValid = false; } @@ -174,8 +269,16 @@ export class SelfBackendVerifier { attestationId, isValidDetails: { isValid, - isOlderThanValid: verificationConfig.olderThan !== undefined ? verificationConfig.olderThan <= Number.parseInt(genericDiscloseOutput.olderThan, 10) : true, - isOfacValid: verificationConfig.ofac !== undefined && verificationConfig.ofac ? genericDiscloseOutput.ofac.every((enabled: boolean, index: number) => enabled ? genericDiscloseOutput.ofac[index] : true) : true, + isOlderThanValid: + verificationConfig.olderThan !== undefined + ? verificationConfig.olderThan <= Number.parseInt(genericDiscloseOutput.olderThan, 10) + : true, + isOfacValid: + verificationConfig.ofac !== undefined && verificationConfig.ofac + ? genericDiscloseOutput.ofac.every((enabled: boolean, index: number) => + enabled ? genericDiscloseOutput.ofac[index] : true + ) + : true, }, forbiddenCountriesList, discloseOutput: genericDiscloseOutput, @@ -183,6 +286,6 @@ export class SelfBackendVerifier { userIdentifier, userDefinedData, }, - } + }; } } diff --git a/sdk/core/src/errors.ts b/sdk/core/src/errors.ts index fd701e11e..2209aafed 100644 --- a/sdk/core/src/errors.ts +++ b/sdk/core/src/errors.ts @@ -8,14 +8,14 @@ export enum ConfigMismatch { InvalidMinimumAge = 'InvalidMinimumAge', InvalidTimestamp = 'InvalidTimestamp', InvalidOfac = 'InvalidOfac', - ConfigNotFound = 'ConfigNotFound' + ConfigNotFound = 'ConfigNotFound', } export class ConfigMismatchError extends Error { public readonly issues: Array<{ type: ConfigMismatch; message: string }>; constructor(issues: Array<{ type: ConfigMismatch; message: string }>) { - const message = issues.map(issue => `[${issue.type}]: ${issue.message}`).join('\n'); + const message = issues.map((issue) => `[${issue.type}]: ${issue.message}`).join('\n'); super(message); this.name = 'ConfigMismatchError'; this.issues = issues; diff --git a/sdk/core/src/store/DefaultConfigStore.ts b/sdk/core/src/store/DefaultConfigStore.ts index b8aec7bd3..0b52b8c18 100644 --- a/sdk/core/src/store/DefaultConfigStore.ts +++ b/sdk/core/src/store/DefaultConfigStore.ts @@ -1,5 +1,5 @@ -import { VerificationConfig } from "src/types/types.js"; -import { IConfigStorage } from "./interface.js"; +import { VerificationConfig } from 'src/types/types.js'; +import { IConfigStorage } from './interface.js'; export class DefaultConfigStore implements IConfigStorage { constructor(private config: VerificationConfig) {} @@ -14,6 +14,6 @@ export class DefaultConfigStore implements IConfigStorage { } async getActionId(_userIdentifier: string, _data: string): Promise { - return ""; + return ''; } } diff --git a/sdk/core/src/store/InMemoryConfigStore.ts b/sdk/core/src/store/InMemoryConfigStore.ts index 7e99f67b3..6fbe0f4bd 100644 --- a/sdk/core/src/store/InMemoryConfigStore.ts +++ b/sdk/core/src/store/InMemoryConfigStore.ts @@ -1,5 +1,5 @@ -import { VerificationConfig } from "src/types/types.js"; -import { IConfigStorage } from "./interface.js"; +import { VerificationConfig } from 'src/types/types.js'; +import { IConfigStorage } from './interface.js'; export class InMemoryConfigStore implements IConfigStorage { private configs: Map = new Map(); diff --git a/sdk/core/src/store/interface.ts b/sdk/core/src/store/interface.ts index 031cd83f5..76fe5a0b0 100644 --- a/sdk/core/src/store/interface.ts +++ b/sdk/core/src/store/interface.ts @@ -1,4 +1,4 @@ -import { VerificationConfig } from "../types/types.js"; +import { VerificationConfig } from '../types/types.js'; export interface IConfigStorage { /** diff --git a/sdk/core/src/types/types.ts b/sdk/core/src/types/types.ts index 4eaa6aab3..d697e8058 100644 --- a/sdk/core/src/types/types.ts +++ b/sdk/core/src/types/types.ts @@ -27,7 +27,7 @@ export type VerificationResult = { userIdentifier: string; userDefinedData: string; }; -} +}; export type GenericDiscloseOutput = { nullifier: string; @@ -41,6 +41,6 @@ export type GenericDiscloseOutput = { expiryDate: string; olderThan: string; ofac: boolean[]; -} +}; export type AttestationId = keyof typeof discloseIndices; diff --git a/sdk/core/src/utils/constants.ts b/sdk/core/src/utils/constants.ts index 9c3303893..eac76653f 100644 --- a/sdk/core/src/utils/constants.ts +++ b/sdk/core/src/utils/constants.ts @@ -1,4 +1,4 @@ -import { AttestationId } from "src/types/types.js"; +import { AttestationId } from 'src/types/types.js'; export const discloseIndices = { 1: { @@ -26,12 +26,24 @@ export const discloseIndices = { scopeIndex: 19, userIdentifierIndex: 20, passportNoSmtRootIndex: 99, - } + }, } as const; -type RevealedDataFields = 'issuingState' | 'name' | 'idNumber' | 'nationality' | 'dateOfBirth' | 'gender' | 'expiryDate' | 'olderThan' | 'ofac'; +type RevealedDataFields = + | 'issuingState' + | 'name' + | 'idNumber' + | 'nationality' + | 'dateOfBirth' + | 'gender' + | 'expiryDate' + | 'olderThan' + | 'ofac'; -export const revealedDataIndices: Record> = { +export const revealedDataIndices: Record< + AttestationId, + Record<`${RevealedDataFields}Start` | `${RevealedDataFields}End`, number> +> = { 1: { issuingStateStart: 2, issuingStateEnd: 4, @@ -71,8 +83,10 @@ export const revealedDataIndices: Record [Number(id), true] as [number, boolean]); +const allIdEntries = Object.keys(discloseIndices).map( + (id) => [Number(id), true] as [number, boolean] +); export const AllIds = new Map(allIdEntries); diff --git a/sdk/core/src/utils/hash.ts b/sdk/core/src/utils/hash.ts index 71882dc9d..eeef33942 100644 --- a/sdk/core/src/utils/hash.ts +++ b/sdk/core/src/utils/hash.ts @@ -1,4 +1,4 @@ -import { createHash } from "crypto"; +import { createHash } from 'crypto'; /** * Generates a deterministic user identifier hash from the provided context data. @@ -9,9 +9,7 @@ import { createHash } from "crypto"; * @returns A 40-character hexadecimal user identifier string prefixed with "0x" */ export function calculateUserIdentifierHash(userContextData: Buffer): string { - const sha256Hash = createHash("sha256") - .update(userContextData) - .digest(); - const ripemdHash = createHash("ripemd160").update(sha256Hash).digest(); - return "0x" + ripemdHash.toString("hex").padStart(40, "0"); + const sha256Hash = createHash('sha256').update(userContextData).digest(); + const ripemdHash = createHash('ripemd160').update(sha256Hash).digest(); + return '0x' + ripemdHash.toString('hex').padStart(40, '0'); } diff --git a/sdk/core/src/utils/id.ts b/sdk/core/src/utils/id.ts index f10f7313c..c910da891 100644 --- a/sdk/core/src/utils/id.ts +++ b/sdk/core/src/utils/id.ts @@ -1,24 +1,78 @@ -import { discloseIndices, revealedDataIndices } from "./constants.js"; -import { AttestationId, GenericDiscloseOutput } from "src/types/types.js"; -import { getRevealedDataBytes } from "./proof.js"; +import { discloseIndices, revealedDataIndices } from './constants.js'; +import { AttestationId, GenericDiscloseOutput } from 'src/types/types.js'; +import { getRevealedDataBytes } from './proof.js'; -export const formatRevealedDataPacked = (attestationId: AttestationId, publicSignals: string[]): GenericDiscloseOutput => { +export const formatRevealedDataPacked = ( + attestationId: AttestationId, + publicSignals: string[] +): GenericDiscloseOutput => { const revealedDataPacked = getRevealedDataBytes(attestationId, publicSignals); const revealedDataPackedString = Buffer.from(revealedDataPacked); - const nullifier = publicSignals[discloseIndices[attestationId].nullifierIndex]; - const forbiddenCountriesListPacked = publicSignals.slice(discloseIndices[attestationId].forbiddenCountriesListPackedIndex, discloseIndices[attestationId].forbiddenCountriesListPackedIndex + 3); - const issuingState = revealedDataPackedString.subarray(revealedDataIndices[attestationId].issuingStateStart, revealedDataIndices[attestationId].issuingStateEnd + 1).toString("utf-8"); - const name = revealedDataPackedString.subarray(revealedDataIndices[attestationId].nameStart, revealedDataIndices[attestationId].nameEnd + 1).toString("utf-8").replace("<<", " ").replace(/<*/g, ""); - const idNumber = revealedDataPackedString.subarray(revealedDataIndices[attestationId].idNumberStart, revealedDataIndices[attestationId].idNumberEnd + 1).toString("utf-8"); - const nationality = revealedDataPackedString.subarray(revealedDataIndices[attestationId].nationalityStart, revealedDataIndices[attestationId].nationalityEnd + 1).toString("utf-8"); - const dateOfBirth = revealedDataPackedString.subarray(revealedDataIndices[attestationId].dateOfBirthStart, revealedDataIndices[attestationId].dateOfBirthEnd + 1).toString("utf-8"); - const gender = revealedDataPackedString.subarray(revealedDataIndices[attestationId].genderStart, revealedDataIndices[attestationId].genderEnd + 1).toString("utf-8"); - const expiryDate = revealedDataPackedString.subarray(revealedDataIndices[attestationId].expiryDateStart, revealedDataIndices[attestationId].expiryDateEnd + 1).toString("utf-8"); - const olderThan = Buffer.from(revealedDataPackedString.subarray(revealedDataIndices[attestationId].olderThanStart, revealedDataIndices[attestationId].olderThanEnd + 1).map((x) => x + 48)).toString("utf-8"); - const ofac = Array.from(revealedDataPackedString.subarray(revealedDataIndices[attestationId].ofacStart, revealedDataIndices[attestationId].ofacEnd + 1)).map(Boolean); - console.log("ofac",ofac); + const forbiddenCountriesListPacked = publicSignals.slice( + discloseIndices[attestationId].forbiddenCountriesListPackedIndex, + discloseIndices[attestationId].forbiddenCountriesListPackedIndex + 3 + ); + const issuingState = revealedDataPackedString + .subarray( + revealedDataIndices[attestationId].issuingStateStart, + revealedDataIndices[attestationId].issuingStateEnd + 1 + ) + .toString('utf-8'); + const name = revealedDataPackedString + .subarray( + revealedDataIndices[attestationId].nameStart, + revealedDataIndices[attestationId].nameEnd + 1 + ) + .toString('utf-8') + .replace('<<', ' ') + .replace(/<*/g, ''); + const idNumber = revealedDataPackedString + .subarray( + revealedDataIndices[attestationId].idNumberStart, + revealedDataIndices[attestationId].idNumberEnd + 1 + ) + .toString('utf-8'); + const nationality = revealedDataPackedString + .subarray( + revealedDataIndices[attestationId].nationalityStart, + revealedDataIndices[attestationId].nationalityEnd + 1 + ) + .toString('utf-8'); + const dateOfBirth = revealedDataPackedString + .subarray( + revealedDataIndices[attestationId].dateOfBirthStart, + revealedDataIndices[attestationId].dateOfBirthEnd + 1 + ) + .toString('utf-8'); + const gender = revealedDataPackedString + .subarray( + revealedDataIndices[attestationId].genderStart, + revealedDataIndices[attestationId].genderEnd + 1 + ) + .toString('utf-8'); + const expiryDate = revealedDataPackedString + .subarray( + revealedDataIndices[attestationId].expiryDateStart, + revealedDataIndices[attestationId].expiryDateEnd + 1 + ) + .toString('utf-8'); + const olderThan = Buffer.from( + revealedDataPackedString + .subarray( + revealedDataIndices[attestationId].olderThanStart, + revealedDataIndices[attestationId].olderThanEnd + 1 + ) + .map((x) => x + 48) + ).toString('utf-8'); + const ofac = Array.from( + revealedDataPackedString.subarray( + revealedDataIndices[attestationId].ofacStart, + revealedDataIndices[attestationId].ofacEnd + 1 + ) + ).map(Boolean); + console.log('ofac', ofac); return { nullifier: nullifier.toString(), @@ -32,5 +86,5 @@ export const formatRevealedDataPacked = (attestationId: AttestationId, publicSig expiryDate: expiryDate, olderThan: olderThan, ofac: ofac, - } + }; }; diff --git a/sdk/core/src/utils/proof.ts b/sdk/core/src/utils/proof.ts index 299d7e506..a436857af 100644 --- a/sdk/core/src/utils/proof.ts +++ b/sdk/core/src/utils/proof.ts @@ -35,10 +35,15 @@ export const bytesCount: Record = { * @param publicSignals - The array of public signals containing packed revealed data * @returns An array of bytes representing the revealed data for the specified attestation */ -export function getRevealedDataBytes(attestationId: AttestationId, publicSignals: PublicSignals): number[] { +export function getRevealedDataBytes( + attestationId: AttestationId, + publicSignals: PublicSignals +): number[] { let bytes: number[] = []; for (let i = 0; i < getRevealedDataPublicSignalsLength(attestationId); i++) { - let publicSignal = BigInt(publicSignals[discloseIndices[attestationId].revealedDataPackedIndex + i]); + let publicSignal = BigInt( + publicSignals[discloseIndices[attestationId].revealedDataPackedIndex + i] + ); for (let j = 0; j < bytesCount[attestationId][i]; j++) { bytes.push(Number(publicSignal & 0xffn)); publicSignal = publicSignal >> 8n; diff --git a/sdk/core/src/utils/utils.ts b/sdk/core/src/utils/utils.ts index ff8370db6..afbed1bc5 100644 --- a/sdk/core/src/utils/utils.ts +++ b/sdk/core/src/utils/utils.ts @@ -1,4 +1,4 @@ -import { unpackReveal } from "@selfxyz/common/utils/circuits/formatOutputs"; +import { unpackReveal } from '@selfxyz/common/utils/circuits/formatOutputs'; function trimu0000(unpackedReveal: string[]): string[] { return unpackedReveal.filter((value) => value !== '\u0000'); diff --git a/sdk/qrcode/tsup.config.ts b/sdk/qrcode/tsup.config.ts index 4dff6ec9f..f3ad9abbc 100644 --- a/sdk/qrcode/tsup.config.ts +++ b/sdk/qrcode/tsup.config.ts @@ -8,7 +8,7 @@ export const tsup: Options = { dts: true, // generate dts files format: ['cjs', 'esm'], // generate cjs and esm files skipNodeModulesBundle: true, - entryPoints: ['index.ts', "animations/**/*", "components/**/*", "utils/**/*"], + entryPoints: ['index.ts', 'animations/**/*', 'components/**/*', 'utils/**/*'], watch: env === 'development', target: 'es2020', outDir: 'dist', From 7d07dcfaff42939dc20367b1559f03bfac4ca672 Mon Sep 17 00:00:00 2001 From: Ayman Date: Mon, 23 Jun 2025 15:27:10 +0530 Subject: [PATCH 22/25] fix: rm ts expect error directive --- app/src/utils/ethers.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/app/src/utils/ethers.ts b/app/src/utils/ethers.ts index 59d7e4953..9073a57ff 100644 --- a/app/src/utils/ethers.ts +++ b/app/src/utils/ethers.ts @@ -10,7 +10,6 @@ ethers.computeHmac.register((algo, key, data) => { return crypto.createHmac(algo, key).update(data).digest(); }); -// @ts-expect-error ethers.pbkdf2.register((passwd, salt, iter, keylen, algo) => { return crypto.pbkdf2Sync(passwd, salt, iter, keylen, algo); }); From 19d09b202ad5dac3e551d6a1df3337209ae2e22d Mon Sep 17 00:00:00 2001 From: Ayman Date: Mon, 23 Jun 2025 15:35:56 +0530 Subject: [PATCH 23/25] fix: contract tests --- .../IdentityVerificationHubImplV2.sol | 4 + contracts/contracts/example/Airdrop.sol | 336 +++++++++++------- contracts/contracts/example/HappyBirthday.sol | 92 ++--- contracts/test/v2/discloseId.test.ts | 12 +- contracts/test/v2/disclosePassport.test.ts | 14 +- 5 files changed, 275 insertions(+), 183 deletions(-) diff --git a/contracts/contracts/IdentityVerificationHubImplV2.sol b/contracts/contracts/IdentityVerificationHubImplV2.sol index 710dc3b7f..dde470a85 100644 --- a/contracts/contracts/IdentityVerificationHubImplV2.sol +++ b/contracts/contracts/IdentityVerificationHubImplV2.sol @@ -161,6 +161,10 @@ contract IdentityVerificationHubImplV2 is ImplRoot { /// @dev Ensures that the user context data hash matches the user identifier in the proof. error InvalidUserIdentifierInProof(); + /// @notice Thrown when a verification config is not set + /// @dev Ensures that the verification config is set before calling the verify function. + error ConfigNotSet(); + // ==================================================== // Constructor // ==================================================== diff --git a/contracts/contracts/example/Airdrop.sol b/contracts/contracts/example/Airdrop.sol index 060412bb7..533803785 100644 --- a/contracts/contracts/example/Airdrop.sol +++ b/contracts/contracts/example/Airdrop.sol @@ -1,200 +1,288 @@ - // // SPDX-License-Identifier: MIT -// pragma solidity 0.8.28; +// SPDX-License-Identifier: MIT +pragma solidity 0.8.28; -import {Ownable} from "@openzeppelin/contracts/access/Ownable.sol"; import {IERC20, SafeERC20} from "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol"; +import {MerkleProof} from "@openzeppelin/contracts/utils/cryptography/MerkleProof.sol"; +import {Ownable} from "@openzeppelin/contracts/access/Ownable.sol"; import {ISelfVerificationRoot} from "../interfaces/ISelfVerificationRoot.sol"; -import {AttestationId} from "../constants/AttestationId.sol"; import {CircuitAttributeHandlerV2} from "../libraries/CircuitAttributeHandlerV2.sol"; -import {Formatter} from "../libraries/Formatter.sol"; -// import {SelfVerificationRoot} from "../abstract/SelfVerificationRoot.sol"; +import {SelfVerificationRoot} from "../abstract/SelfVerificationRoot.sol"; /** - * @title SelfHappyBirthday V2 - * @notice A contract that gives out USDC to users on their birthday, supporting both E-Passport and EUID cards - * @dev Uses SelfVerificationRoot V2 to handle verification with nullifier management for birthday claims + * @title Airdrop V2 (Experimental) + * @notice This contract manages an airdrop campaign by verifying user registrations with zero‐knowledge proofs + * supporting both E-Passport and EU ID Card attestations, and distributing ERC20 tokens. + * It is provided for testing and demonstration purposes only. + * **WARNING:** This contract has not been audited and is NOT intended for production use. + * @dev Inherits from SelfVerificationRoot V2 for registration logic and Ownable for administrative control. */ -contract SelfHappyBirthday is SelfVerificationRoot, Ownable { +contract Airdrop is SelfVerificationRoot, Ownable { using SafeERC20 for IERC20; // ==================================================== - // Constants + // Storage Variables // ==================================================== - uint256 public constant BASIS_POINTS = 10000; + /// @notice ERC20 token to be airdropped. + IERC20 public immutable token; + + /// @notice Merkle root used to validate airdrop claims. + bytes32 public merkleRoot; + + /// @notice Tracks addresses that have claimed tokens. + mapping(address => bool) public claimed; + + /// @notice Indicates whether the registration phase is active. + bool public isRegistrationOpen; + + /// @notice Indicates whether the claim phase is active. + bool public isClaimOpen; + + /// @notice Maps nullifiers to user identifiers for registration tracking + mapping(uint256 nullifier => uint256 userIdentifier) internal _nullifierToUserIdentifier; + + /// @notice Maps user identifiers to registration status + mapping(uint256 userIdentifier => bool registered) internal _registeredUserIdentifiers; // ==================================================== - // Storage Variables + // Errors // ==================================================== - /// @notice USDC token contract - IERC20 public immutable usdc; + /// @notice Reverts when an invalid Merkle proof is provided. + error InvalidProof(); + + /// @notice Reverts when a user attempts to claim tokens more than once. + error AlreadyClaimed(); - /// @notice Default: 50 dollar (6 decimals for USDC) - uint256 public claimableAmount = 50e6; + /// @notice Reverts when an unregistered address attempts to claim tokens. + error NotRegistered(address nonRegisteredAddress); - /// @notice Bonus multiplier for EUID card users (in basis points) - uint256 public euidBonusMultiplier = 200; // 200% = 100% bonus + /// @notice Reverts when registration is attempted while the registration phase is closed. + error RegistrationNotOpen(); - /// @notice Bonus multiplier for E-Passport card users (in basis points) - uint256 public passportBonusMultiplier = 100; // 100% = 50% bonus + /// @notice Reverts when a claim attempt is made while registration is still open. + error RegistrationNotClosed(); - /// @notice Default: 1 day window around birthday - uint256 public claimableWindow = 1 days; + /// @notice Reverts when a claim is attempted while claiming is not enabled. + error ClaimNotOpen(); - /// @notice Tracks users who have claimed to prevent double claims - mapping(uint256 nullifier => bool hasClaimed) public hasClaimed; + /// @notice Reverts when an invalid user identifier is provided. + error InvalidUserIdentifier(); -// // ==================================================== -// // Events -// // ==================================================== + /// @notice Reverts when a user identifier has already been registered + error UserIdentifierAlreadyRegistered(); - event USDCClaimed(address indexed claimer, uint256 amount, bytes32 attestationId); - event ClaimableAmountUpdated(uint256 oldAmount, uint256 newAmount); - event ClaimableWindowUpdated(uint256 oldWindow, uint256 newWindow); - event EuidBonusMultiplierUpdated(uint256 oldMultiplier, uint256 newMultiplier); + /// @notice Reverts when a nullifier has already been registered + error RegisteredNullifier(); // ==================================================== - // Errors + // Events // ==================================================== - error NotWithinBirthdayWindow(); - error AlreadyClaimed(); + /// @notice Emitted when a user successfully claims tokens. + /// @param index The index of the claim in the Merkle tree. + /// @param account The address that claimed tokens. + /// @param amount The amount of tokens claimed. + event Claimed(uint256 index, address account, uint256 amount); + + /// @notice Emitted when the registration phase is opened. + event RegistrationOpen(); + + /// @notice Emitted when the registration phase is closed. + event RegistrationClose(); + + /// @notice Emitted when the claim phase is opened. + event ClaimOpen(); + + /// @notice Emitted when the claim phase is closed. + event ClaimClose(); + + /// @notice Emitted when a user identifier is registered. + event UserIdentifierRegistered(uint256 indexed registeredUserIdentifier, uint256 indexed nullifier); + + /// @notice Emitted when the Merkle root is updated. + event MerkleRootUpdated(bytes32 newMerkleRoot); + + // ==================================================== + // Constructor + // ==================================================== /** - * @notice Initializes the HappyBirthday V2 contract - * @param identityVerificationHubAddress The address of the Identity Verification Hub V2 - * @param scopeValue The expected proof scope for user registration - * @param token The USDC token address + * @notice Constructor for the experimental Airdrop V2 contract. + * @dev Initializes the airdrop parameters, zero-knowledge verification configuration, + * and sets the ERC20 token to be distributed. Supports both E-Passport and EUID attestations. + * @param identityVerificationHubAddress The address of the Identity Verification Hub V2. + * @param scopeValue The expected proof scope for user registration. + * @param tokenAddress The address of the ERC20 token for airdrop. */ constructor( address identityVerificationHubAddress, uint256 scopeValue, - address token + address tokenAddress ) SelfVerificationRoot(identityVerificationHubAddress, scopeValue) Ownable(_msgSender()) { - usdc = IERC20(token); + token = IERC20(tokenAddress); + } + + // ==================================================== + // External/Public Functions + // ==================================================== + + /** + * @notice Sets the Merkle root for claim validation. + * @dev Only callable by the contract owner. + * @param newMerkleRoot The new Merkle root. + */ + function setMerkleRoot(bytes32 newMerkleRoot) external onlyOwner { + merkleRoot = newMerkleRoot; + emit MerkleRootUpdated(newMerkleRoot); + } + + /** + * @notice Updates the scope used for verification. + * @dev Only callable by the contract owner. + * @param newScope The new scope to set. + */ + function setScope(uint256 newScope) external onlyOwner { + _setScope(newScope); } -// // ==================================================== -// // External/Public Functions -// // ==================================================== + /** + * @notice Opens the registration phase for users. + * @dev Only callable by the contract owner. + */ + function openRegistration() external onlyOwner { + isRegistrationOpen = true; + emit RegistrationOpen(); + } /** - * @notice Sets the claimable USDC amount - * @param newAmount The new claimable amount + * @notice Closes the registration phase. + * @dev Only callable by the contract owner. */ - function setClaimableAmount(uint256 newAmount) external onlyOwner { - uint256 oldAmount = claimableAmount; - claimableAmount = newAmount; - emit ClaimableAmountUpdated(oldAmount, newAmount); + function closeRegistration() external onlyOwner { + isRegistrationOpen = false; + emit RegistrationClose(); } /** - * @notice Sets the claimable window around birthdays - * @param newWindow The new claimable window in seconds + * @notice Opens the claim phase, allowing registered users to claim tokens. + * @dev Only callable by the contract owner. */ - function setClaimableWindow(uint256 newWindow) external onlyOwner { - uint256 oldWindow = claimableWindow; - claimableWindow = newWindow; - emit ClaimableWindowUpdated(oldWindow, newWindow); + function openClaim() external onlyOwner { + isClaimOpen = true; + emit ClaimOpen(); } /** - * @notice Sets the EUID bonus multiplier for EUID card users - * @param newMultiplier The new bonus multiplier in basis points (10000 = 100%) + * @notice Closes the claim phase. + * @dev Only callable by the contract owner. */ - function setEuidBonusMultiplier(uint256 newMultiplier) external onlyOwner { - uint256 oldMultiplier = euidBonusMultiplier; - euidBonusMultiplier = newMultiplier; - emit EuidBonusMultiplierUpdated(oldMultiplier, newMultiplier); + function closeClaim() external onlyOwner { + isClaimOpen = false; + emit ClaimClose(); } /** - * @notice Allows the owner to withdraw USDC from the contract - * @param to The address to withdraw to - * @param amount The amount to withdraw + * @notice Retrieves the expected proof scope. + * @return The scope value used for registration verification. */ - function withdrawUSDC(address to, uint256 amount) external onlyOwner { - usdc.safeTransfer(to, amount); + function getScope() external view returns (uint256) { + return _scope; } -// // ==================================================== -// // Override Functions from SelfVerificationRoot -// // ==================================================== + /** + * @notice Checks if a given address is registered. + * @param registeredAddress The address to check. + * @return True if the address is registered, false otherwise. + */ + function isRegistered(address registeredAddress) external view returns (bool) { + return _registeredUserIdentifiers[uint256(uint160(registeredAddress))]; + } /** - * @notice Hook called after successful verification - * @dev Checks user hasn't claimed, validates birthday window, and transfers USDC if eligible + * @notice Allows a registered user to claim their tokens. + * @dev Reverts if registration is still open, if claiming is disabled, if already claimed, + * or if the sender is not registered. Also validates the claim using a Merkle proof. + * @param index The index of the claim in the Merkle tree. + * @param amount The amount of tokens to be claimed. + * @param merkleProof The Merkle proof verifying the claim. + */ + function claim(uint256 index, uint256 amount, bytes32[] memory merkleProof) external { + if (isRegistrationOpen) { + revert RegistrationNotClosed(); + } + if (!isClaimOpen) { + revert ClaimNotOpen(); + } + if (claimed[msg.sender]) { + revert AlreadyClaimed(); + } + if (!_registeredUserIdentifiers[uint256(uint160(msg.sender))]) { + revert NotRegistered(msg.sender); + } + + // Verify the Merkle proof. + bytes32 node = keccak256(abi.encodePacked(index, msg.sender, amount)); + if (!MerkleProof.verify(merkleProof, merkleRoot, node)) revert InvalidProof(); + + // Mark as claimed and transfer tokens. + _setClaimed(); + token.safeTransfer(msg.sender, amount); + + emit Claimed(index, msg.sender, amount); + } + + // ==================================================== + // Override Functions from SelfVerificationRoot + // ==================================================== + + /** + * @notice Hook called after successful verification - handles user registration + * @dev Validates registration conditions and registers the user for both E-Passport and EUID attestations * @param output The verification output containing user data */ function customVerificationHook( ISelfVerificationRoot.GenericDiscloseOutputV2 memory output, bytes memory /* userData */ ) internal override { - // Check if user has already claimed - if (hasClaimed[output.nullifier]) { - revert AlreadyClaimed(); + // Check if registration is open + if (!isRegistrationOpen) { + revert RegistrationNotOpen(); } - // Check if within birthday window using V2 attribute handler - if (_isWithinBirthdayWindow(output.attestationId, output.dateOfBirth)) { - // Calculate final amount based on attestation type - uint256 finalAmount = claimableAmount; - - // Apply bonus multiplier for EUID card users - if (output.attestationId == AttestationId.EU_ID_CARD) { - finalAmount = (claimableAmount * euidBonusMultiplier) / BASIS_POINTS; - } + // Check if nullifier has already been registered + if (_nullifierToUserIdentifier[output.nullifier] != 0) { + revert RegisteredNullifier(); + } - // Mark user as claimed - hasClaimed[output.nullifier] = true; + // Check if user identifier is valid + if (output.userIdentifier == 0) { + revert InvalidUserIdentifier(); + } - address recipient = address(uint160(output.userIdentifier)); + // Check if user identifier has already been registered + if (_registeredUserIdentifiers[output.userIdentifier]) { + revert UserIdentifierAlreadyRegistered(); + } - // Transfer USDC to the user - usdc.safeTransfer(recipient, finalAmount); + _nullifierToUserIdentifier[output.nullifier] = output.userIdentifier; + _registeredUserIdentifiers[output.userIdentifier] = true; - // Emit success event - emit USDCClaimed(recipient, finalAmount, output.attestationId); - } else { - revert NotWithinBirthdayWindow(); - } + // Emit registration event + emit UserIdentifierRegistered(output.userIdentifier, output.nullifier); } -// // ==================================================== -// // Internal Functions -// // ==================================================== + // ==================================================== + // Internal Functions + // ==================================================== /** - * @notice Checks if the current date is within the user's birthday window - * @param attestationId The attestation type (E-Passport or EUID) - * @param dobFromProof The date of birth extracted from the proof (format: "DD-MM-YY") - * @return isWithinWindow True if within the birthday window + * @notice Internal function to mark the caller as having claimed their tokens. + * @dev Updates the claimed mapping. */ - function _isWithinBirthdayWindow(bytes32 attestationId, string memory dobFromProof) internal view returns (bool) { - // DOB comes in format "DD-MM-YY" from the proof system - bytes memory dobBytes = bytes(dobFromProof); - require(dobBytes.length == 8, "Invalid DOB format"); // "DD-MM-YY" = 8 chars - - // Extract day and month from "DD-MM-YY" format - string memory day = Formatter.substring(dobFromProof, 0, 2); // DD - string memory month = Formatter.substring(dobFromProof, 3, 5); // MM (skip hyphen at index 2) - - // Create birthday in current year (format: YYMMDD) - string memory dobInThisYear = string(abi.encodePacked("25", month, day)); - uint256 dobInThisYearTimestamp = Formatter.dateToUnixTimestamp(dobInThisYear); - - uint256 currentTime = block.timestamp; - uint256 timeDifference; - - if (currentTime > dobInThisYearTimestamp) { - timeDifference = currentTime - dobInThisYearTimestamp; - } else { - timeDifference = dobInThisYearTimestamp - currentTime; - } - - return timeDifference <= claimableWindow; + function _setClaimed() internal { + claimed[msg.sender] = true; } } diff --git a/contracts/contracts/example/HappyBirthday.sol b/contracts/contracts/example/HappyBirthday.sol index 26ca5ac1c..d372dca3d 100644 --- a/contracts/contracts/example/HappyBirthday.sol +++ b/contracts/contracts/example/HappyBirthday.sol @@ -1,8 +1,8 @@ - // // SPDX-License-Identifier: MIT -// pragma solidity 0.8.28; +// SPDX-License-Identifier: MIT +pragma solidity 0.8.28; -// import {Ownable} from "@openzeppelin/contracts/access/Ownable.sol"; -// import {IERC20, SafeERC20} from "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol"; +import {Ownable} from "@openzeppelin/contracts/access/Ownable.sol"; +import {IERC20, SafeERC20} from "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol"; import {ISelfVerificationRoot} from "../interfaces/ISelfVerificationRoot.sol"; import {AttestationId} from "../constants/AttestationId.sol"; @@ -29,8 +29,8 @@ contract SelfHappyBirthday is SelfVerificationRoot, Ownable { // Storage Variables // ==================================================== -// /// @notice USDC token contract -// IERC20 public immutable usdc; + /// @notice USDC token contract + IERC20 public immutable usdc; /// @notice Default: 50 dollar (6 decimals for USDC) uint256 public claimableAmount = 50e6; @@ -41,27 +41,27 @@ contract SelfHappyBirthday is SelfVerificationRoot, Ownable { /// @notice Bonus multiplier for E-Passport card users (in basis points) uint256 public passportBonusMultiplier = 100; // 100% = 50% bonus -// /// @notice Default: 1 day window around birthday -// uint256 public claimableWindow = 1 days; + /// @notice Default: 1 day window around birthday + uint256 public claimableWindow = 1 days; -// /// @notice Tracks users who have claimed to prevent double claims -// mapping(uint256 nullifier => bool hasClaimed) public hasClaimed; + /// @notice Tracks users who have claimed to prevent double claims + mapping(uint256 nullifier => bool hasClaimed) public hasClaimed; -// // ==================================================== -// // Events -// // ==================================================== + // ==================================================== + // Events + // ==================================================== event USDCClaimed(address indexed claimer, uint256 amount, bytes32 attestationId); event ClaimableAmountUpdated(uint256 oldAmount, uint256 newAmount); event ClaimableWindowUpdated(uint256 oldWindow, uint256 newWindow); event EuidBonusMultiplierUpdated(uint256 oldMultiplier, uint256 newMultiplier); -// // ==================================================== -// // Errors -// // ==================================================== + // ==================================================== + // Errors + // ==================================================== -// error NotWithinBirthdayWindow(); -// error AlreadyClaimed(); + error NotWithinBirthdayWindow(); + error AlreadyClaimed(); /** * @notice Initializes the HappyBirthday V2 contract @@ -77,9 +77,9 @@ contract SelfHappyBirthday is SelfVerificationRoot, Ownable { usdc = IERC20(token); } -// // ==================================================== -// // External/Public Functions -// // ==================================================== + // ==================================================== + // External/Public Functions + // ==================================================== /** * @notice Sets the claimable USDC amount @@ -91,15 +91,15 @@ contract SelfHappyBirthday is SelfVerificationRoot, Ownable { emit ClaimableAmountUpdated(oldAmount, newAmount); } -// /** -// * @notice Sets the claimable window around birthdays -// * @param newWindow The new claimable window in seconds -// */ -// function setClaimableWindow(uint256 newWindow) external onlyOwner { -// uint256 oldWindow = claimableWindow; -// claimableWindow = newWindow; -// emit ClaimableWindowUpdated(oldWindow, newWindow); -// } + /** + * @notice Sets the claimable window around birthdays + * @param newWindow The new claimable window in seconds + */ + function setClaimableWindow(uint256 newWindow) external onlyOwner { + uint256 oldWindow = claimableWindow; + claimableWindow = newWindow; + emit ClaimableWindowUpdated(oldWindow, newWindow); + } /** * @notice Sets the EUID bonus multiplier for EUID card users @@ -120,9 +120,9 @@ contract SelfHappyBirthday is SelfVerificationRoot, Ownable { usdc.safeTransfer(to, amount); } -// // ==================================================== -// // Override Functions from SelfVerificationRoot -// // ==================================================== + // ==================================================== + // Override Functions from SelfVerificationRoot + // ==================================================== /** * @notice Hook called after successful verification @@ -163,9 +163,9 @@ contract SelfHappyBirthday is SelfVerificationRoot, Ownable { } } -// // ==================================================== -// // Internal Functions -// // ==================================================== + // ==================================================== + // Internal Functions + // ==================================================== /** * @notice Checks if the current date is within the user's birthday window @@ -186,15 +186,15 @@ contract SelfHappyBirthday is SelfVerificationRoot, Ownable { string memory dobInThisYear = string(abi.encodePacked("25", month, day)); uint256 dobInThisYearTimestamp = Formatter.dateToUnixTimestamp(dobInThisYear); -// uint256 currentTime = block.timestamp; -// uint256 timeDifference; + uint256 currentTime = block.timestamp; + uint256 timeDifference; -// if (currentTime > dobInThisYearTimestamp) { -// timeDifference = currentTime - dobInThisYearTimestamp; -// } else { -// timeDifference = dobInThisYearTimestamp - currentTime; -// } + if (currentTime > dobInThisYearTimestamp) { + timeDifference = currentTime - dobInThisYearTimestamp; + } else { + timeDifference = dobInThisYearTimestamp - currentTime; + } -// return timeDifference <= claimableWindow; -// } -// } + return timeDifference <= claimableWindow; + } +} diff --git a/contracts/test/v2/discloseId.test.ts b/contracts/test/v2/discloseId.test.ts index c84e6fd5c..cf86e2359 100644 --- a/contracts/test/v2/discloseId.test.ts +++ b/contracts/test/v2/discloseId.test.ts @@ -122,7 +122,7 @@ describe("Self Verification Flow V2 - ID Card", () => { undefined, undefined, forbiddenCountriesList, - userIdentifierBigInt.toString(16).padStart(64, "0"), + "0x" + userIdentifierBigInt.toString(16).padStart(64, "0"), ); pristineBaseVcAndDiscloseProof = structuredClone(baseVcAndDiscloseProof); @@ -307,7 +307,7 @@ describe("Self Verification Flow V2 - ID Card", () => { undefined, undefined, forbiddenCountriesList, - userIdentifierBigInt.toString(16).padStart(64, "0"), + "0x" + userIdentifierBigInt.toString(16).padStart(64, "0"), ); const encodedProof = ethers.AbiCoder.defaultAbiCoder().encode( @@ -667,7 +667,7 @@ describe("Self Verification Flow V2 - ID Card", () => { nameAndYob_smt, "0", // This will make OFAC verification fail forbiddenCountriesList, - userIdentifierBigInt.toString(16).padStart(64, "0"), + "0x" + userIdentifierBigInt.toString(16).padStart(64, "0"), ); const encodedProof = ethers.AbiCoder.defaultAbiCoder().encode( @@ -731,7 +731,7 @@ describe("Self Verification Flow V2 - ID Card", () => { nameAndYob_smt, "1", forbiddenCountriesList, // Use the original forbidden countries list (different from config) - userIdentifierBigInt.toString(16).padStart(64, "0"), + "0x" + userIdentifierBigInt.toString(16).padStart(64, "0"), ); const encodedProof = ethers.AbiCoder.defaultAbiCoder().encode( @@ -796,7 +796,7 @@ describe("Self Verification Flow V2 - ID Card", () => { nameAndYob_smt, "1", forbiddenCountriesList, - userIdentifierBigInt.toString(16).padStart(64, "0"), + "0x" + userIdentifierBigInt.toString(16).padStart(64, "0"), ); const encodedProof = ethers.AbiCoder.defaultAbiCoder().encode( @@ -861,7 +861,7 @@ describe("Self Verification Flow V2 - ID Card", () => { nameAndYob_smt, "1", forbiddenCountriesList, - userIdentifierBigInt.toString(16).padStart(64, "0"), + "0x" + userIdentifierBigInt.toString(16).padStart(64, "0"), ); const encodedProof = ethers.AbiCoder.defaultAbiCoder().encode( diff --git a/contracts/test/v2/disclosePassport.test.ts b/contracts/test/v2/disclosePassport.test.ts index 1987c815f..e4bc9c754 100644 --- a/contracts/test/v2/disclosePassport.test.ts +++ b/contracts/test/v2/disclosePassport.test.ts @@ -116,7 +116,7 @@ describe("Self Verification Flow V2", () => { undefined, undefined, forbiddenCountriesList, - userIdentifierBigInt.toString(16).padStart(64, "0"), + "0x" + userIdentifierBigInt.toString(16).padStart(64, "0"), ); pristineBaseVcAndDiscloseProof = structuredClone(baseVcAndDiscloseProof); @@ -298,7 +298,7 @@ describe("Self Verification Flow V2", () => { undefined, undefined, forbiddenCountriesList, - userIdentifierBigInt.toString(16).padStart(64, "0"), + "0x" + userIdentifierBigInt.toString(16).padStart(64, "0"), ); const encodedProof = ethers.AbiCoder.defaultAbiCoder().encode( @@ -418,7 +418,7 @@ describe("Self Verification Flow V2", () => { undefined, undefined, forbiddenCountriesList, - userIdentifierBigInt.toString(16).padStart(64, "0"), + "0x" + userIdentifierBigInt.toString(16).padStart(64, "0"), ); const encodedProof = ethers.AbiCoder.defaultAbiCoder().encode( @@ -695,7 +695,7 @@ describe("Self Verification Flow V2", () => { nameAndYob_smt, "0", // This will make OFAC verification fail forbiddenCountriesList, - userIdentifierBigInt.toString(16).padStart(64, "0"), + "0x" + userIdentifierBigInt.toString(16).padStart(64, "0"), ); const encodedProof = ethers.AbiCoder.defaultAbiCoder().encode( @@ -768,7 +768,7 @@ describe("Self Verification Flow V2", () => { undefined, undefined, forbiddenCountriesList, // Use the original forbidden countries list (different from config) - userIdentifierBigInt.toString(16).padStart(64, "0"), + "0x" + userIdentifierBigInt.toString(16).padStart(64, "0"), ); const encodedProof = ethers.AbiCoder.defaultAbiCoder().encode( @@ -829,7 +829,7 @@ describe("Self Verification Flow V2", () => { undefined, undefined, forbiddenCountriesList, - userIdentifierBigInt.toString(16).padStart(64, "0"), + "0x" + userIdentifierBigInt.toString(16).padStart(64, "0"), ); const encodedProof = ethers.AbiCoder.defaultAbiCoder().encode( @@ -890,7 +890,7 @@ describe("Self Verification Flow V2", () => { undefined, undefined, forbiddenCountriesList, - userIdentifierBigInt.toString(16).padStart(64, "0"), + "0x" + userIdentifierBigInt.toString(16).padStart(64, "0"), ); const encodedProof = ethers.AbiCoder.defaultAbiCoder().encode( From c1e5ff7eaac01e6c148c473ebed38745da0a3ceb Mon Sep 17 00:00:00 2001 From: Ayman Date: Mon, 23 Jun 2025 16:36:03 +0530 Subject: [PATCH 24/25] use excluded countries instead forbidden countries list --- sdk/core/src/SelfBackendVerifier.ts | 2 +- sdk/core/src/types/types.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/sdk/core/src/SelfBackendVerifier.ts b/sdk/core/src/SelfBackendVerifier.ts index 4163f4fcd..540d00f12 100644 --- a/sdk/core/src/SelfBackendVerifier.ts +++ b/sdk/core/src/SelfBackendVerifier.ts @@ -147,7 +147,7 @@ export class SelfBackendVerifier { (x) => publicSignals[discloseIndices[attestationId].forbiddenCountriesListPackedIndex + x] ) ); - const forbiddenCountriesListVerificationConfig = verificationConfig.forbiddenCountriesList; + const forbiddenCountriesListVerificationConfig = verificationConfig.excludedCountries; const isForbiddenCountryListValid = forbiddenCountriesListVerificationConfig.every((country) => forbiddenCountriesList.includes(country as Country3LetterCode) diff --git a/sdk/core/src/types/types.ts b/sdk/core/src/types/types.ts index d697e8058..2338ae60e 100644 --- a/sdk/core/src/types/types.ts +++ b/sdk/core/src/types/types.ts @@ -10,7 +10,7 @@ export type VcAndDiscloseProof = { export type VerificationConfig = { olderThan?: number; - forbiddenCountriesList?: Country3LetterCode[]; + excludedCountries?: Country3LetterCode[]; ofac?: boolean; }; From d09bb313b64edbb525efdd05e82e96c65c40a769 Mon Sep 17 00:00:00 2001 From: Ayman Date: Mon, 23 Jun 2025 17:16:15 +0530 Subject: [PATCH 25/25] chore: change types in constnats --- sdk/core/src/utils/constants.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sdk/core/src/utils/constants.ts b/sdk/core/src/utils/constants.ts index eac76653f..81992b070 100644 --- a/sdk/core/src/utils/constants.ts +++ b/sdk/core/src/utils/constants.ts @@ -87,6 +87,6 @@ export const revealedDataIndices: Record< } as const; const allIdEntries = Object.keys(discloseIndices).map( - (id) => [Number(id), true] as [number, boolean] + (id) => [Number(id) as AttestationId, true] as [AttestationId, boolean] ); -export const AllIds = new Map(allIdEntries); +export const AllIds = new Map(allIdEntries);