From ce66d234392c12129fdd25a1c1e3765018c70d54 Mon Sep 17 00:00:00 2001 From: Andy Wang <41224501+andy-t-wang@users.noreply.github.com> Date: Mon, 3 Jun 2024 16:08:49 -0700 Subject: [PATCH 1/2] Cleanup Clean up minikit and remove IDKit core dependency --- .../ClientContent/VerifyAction/index.tsx | 25 +++++++------------ .../VerifyAction/verify-cloud-proof.ts | 7 +++--- demo/with-next/package.json | 1 - pnpm-lock.yaml | 3 --- src/index.ts | 7 +++++- src/types/errors.ts | 3 --- 6 files changed, 18 insertions(+), 28 deletions(-) diff --git a/demo/with-next/components/ClientContent/VerifyAction/index.tsx b/demo/with-next/components/ClientContent/VerifyAction/index.tsx index a2ab1d5..cb702da 100644 --- a/demo/with-next/components/ClientContent/VerifyAction/index.tsx +++ b/demo/with-next/components/ClientContent/VerifyAction/index.tsx @@ -1,9 +1,10 @@ -import { IDKitConfig, VerificationLevel } from "@worldcoin/idkit-core"; import { MiniKit, ResponseEvent, VerificationErrorCodes, VerifyCommandInput, + VerificationLevel, + ISuccessResult, } from "@worldcoin/minikit-js"; import { useCallback, useEffect, useState } from "react"; import * as yup from "yup"; @@ -53,9 +54,9 @@ export const VerifyAction = () => { any > | null>(null); - const [lastUsedAppId, setLastUsedAppId] = useState< - IDKitConfig["app_id"] | null - >(null); + const [lastUsedAppId, setLastUsedAppId] = useState<`app_${string}` | null>( + null + ); const [lastUsedAction, setLastUsedAction] = useState(null); @@ -101,12 +102,7 @@ export const VerifyAction = () => { } const verifyResponse = await verifyProof({ - payload: { - proof: payload.proof, - merkle_root: payload.merkle_root, - nullifier_hash: payload.nullifier_hash, - verification_level: payload.verification_level, - }, + payload: payload as ISuccessResult, app_id: lastUsedAppId, action: lastUsedAction, }); @@ -121,7 +117,7 @@ export const VerifyAction = () => { const verifyAction = useCallback( (params: { - app_id: IDKitConfig["app_id"]; + app_id: `app_${string}`; action: string; verification_level?: VerificationLevel; }) => { @@ -148,9 +144,7 @@ export const VerifyAction = () => { const onProdVerifyClick = useCallback( (verification_level: VerificationLevel) => { verifyAction({ - app_id: process.env - .NEXT_PUBLIC_PROD_VERIFY_APP_ID as IDKitConfig["app_id"], - + app_id: process.env.NEXT_PUBLIC_PROD_VERIFY_APP_ID as `app_${string}`, action: process.env.NEXT_PUBLIC_PROD_VERIFY_ACTION as string, verification_level, }); @@ -162,8 +156,7 @@ export const VerifyAction = () => { (verification_level: VerificationLevel) => { verifyAction({ app_id: process.env - .NEXT_PUBLIC_STAGING_VERIFY_APP_ID as IDKitConfig["app_id"], - + .NEXT_PUBLIC_STAGING_VERIFY_APP_ID as `app_${string}`, action: process.env.NEXT_PUBLIC_STAGING_VERIFY_ACTION as string, verification_level, }); diff --git a/demo/with-next/components/ClientContent/VerifyAction/verify-cloud-proof.ts b/demo/with-next/components/ClientContent/VerifyAction/verify-cloud-proof.ts index 53557c0..37dade4 100644 --- a/demo/with-next/components/ClientContent/VerifyAction/verify-cloud-proof.ts +++ b/demo/with-next/components/ClientContent/VerifyAction/verify-cloud-proof.ts @@ -1,14 +1,13 @@ "use server"; -import { IDKitConfig, ISuccessResult } from "@worldcoin/idkit-core"; - import { + ISuccessResult, IVerifyResponse, verifyCloudProof, -} from "@worldcoin/idkit-core/backend"; +} from "@worldcoin/minikit-js"; export const verifyProof = async (params: { - app_id: IDKitConfig["app_id"]; + app_id: `app_${string}`; action: string; payload: ISuccessResult; }) => { diff --git a/demo/with-next/package.json b/demo/with-next/package.json index 8e62d33..d7ba0cb 100644 --- a/demo/with-next/package.json +++ b/demo/with-next/package.json @@ -10,7 +10,6 @@ "typecheck": "tsc" }, "dependencies": { - "@worldcoin/idkit-core": "^1.2.0", "@worldcoin/minikit-js": "workspace:*", "clsx": "^2.1.1", "next": "14.2.1", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index ef26b0b..d8e0eb6 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -14,9 +14,6 @@ importers: demo/with-next: dependencies: - '@worldcoin/idkit-core': - specifier: ^1.2.0 - version: 1.2.0(@types/react@18.2.79)(react@18.2.0)(typescript@5.4.5) '@worldcoin/minikit-js': specifier: workspace:* version: link:../../src diff --git a/src/index.ts b/src/index.ts index dba0bc9..c37e332 100644 --- a/src/index.ts +++ b/src/index.ts @@ -39,4 +39,9 @@ export { export { Tokens, Network, TokenDecimals } from "./types/payment"; export { tokenToDecimals } from "helpers/payment/client"; -export { VerificationLevel } from "@worldcoin/idkit-core"; + +export { VerificationLevel, ISuccessResult } from "@worldcoin/idkit-core"; +export { + verifyCloudProof, + IVerifyResponse, +} from "@worldcoin/idkit-core/backend"; diff --git a/src/types/errors.ts b/src/types/errors.ts index 12a7f3d..b506d1a 100644 --- a/src/types/errors.ts +++ b/src/types/errors.ts @@ -49,15 +49,12 @@ export enum PaymentErrorMessage { } export enum WalletAuthErrorCodes { - InvalidAddress = "invalid_address", MalformedRequest = "malformed_request", UserRejected = "user_rejected", GenericError = "generic_error", } export const WalletAuthErrorMessage = { - [WalletAuthErrorCodes.InvalidAddress]: - "The specified address is not valid for the connected wallet.", [WalletAuthErrorCodes.MalformedRequest]: "Provided parameters in the request are invalid.", [WalletAuthErrorCodes.UserRejected]: "User rejected the request.", From 9f596a9133105a24dfda092938962af105f91eb3 Mon Sep 17 00:00:00 2001 From: Andy Wang <41224501+andy-t-wang@users.noreply.github.com> Date: Tue, 4 Jun 2024 09:10:37 -0700 Subject: [PATCH 2/2] Update exports to specify type --- src/index.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/index.ts b/src/index.ts index c37e332..9a5d27f 100644 --- a/src/index.ts +++ b/src/index.ts @@ -40,8 +40,8 @@ export { export { Tokens, Network, TokenDecimals } from "./types/payment"; export { tokenToDecimals } from "helpers/payment/client"; -export { VerificationLevel, ISuccessResult } from "@worldcoin/idkit-core"; +export { VerificationLevel, type ISuccessResult } from "@worldcoin/idkit-core"; export { verifyCloudProof, - IVerifyResponse, + type IVerifyResponse, } from "@worldcoin/idkit-core/backend";