Skip to content

Commit

Permalink
Update zk-email-sdk
Browse files Browse the repository at this point in the history
  • Loading branch information
wryonik committed Aug 20, 2024
1 parent 067780f commit 8cde0e1
Show file tree
Hide file tree
Showing 4 changed files with 160 additions and 115 deletions.
2 changes: 1 addition & 1 deletion packages/app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"@rainbow-me/rainbowkit": "^1.3.3",
"@react-oauth/google": "^0.12.1",
"@zk-email/helpers": "^6.1.3",
"@zk-email/zk-regex-sdk": "^1.0.2",
"@zk-email/zk-email-sdk": "^1.0.3",
"js-base64": "^3.7.7",
"lodash": "^4.17.21",
"react": "^17.0.2",
Expand Down
8 changes: 4 additions & 4 deletions packages/app/src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import {
import "@rainbow-me/rainbowkit/styles.css";
import { GoogleOAuthProvider } from "@react-oauth/google";
import { GoogleAuthProvider } from "./contexts/GoogleAuth";
import { ZkRegexProvider } from "@zk-email/zk-regex-sdk";
import { ZkEmailSDKProvider } from "@zk-email/zk-email-sdk";

const { connectors } = getDefaultWallets({
appName: "ZK Email - Twitter Verifier",
Expand All @@ -33,9 +33,9 @@ const config = createConfig({

ReactDOM.render(
<React.StrictMode>
<ZkRegexProvider
<ZkEmailSDKProvider
clientId={import.meta.env.VITE_GOOGLE_CLIENT_ID}
zkRegexRegistryUrl="https://registry-dev.zkregex.com"
zkEmailSDKRegistryUrl="https://registry-dev.zkregex.com"
>
<WagmiConfig config={config}>
<RainbowKitProvider chains={[sepolia]} theme={darkTheme()}>
Expand All @@ -46,7 +46,7 @@ ReactDOM.render(
</GoogleOAuthProvider>
</RainbowKitProvider>
</WagmiConfig>{" "}
</ZkRegexProvider>
</ZkEmailSDKProvider>
</React.StrictMode>,
document.getElementById("root")
);
23 changes: 20 additions & 3 deletions packages/app/src/pages/MainPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ import {
import { formatDateTime } from "../helpers/dateTimeFormat";
import EmailInputMethod from "../components/EmailInputMethod";
import { randomUUID } from "crypto";
import { useZkRegex } from "@zk-email/zk-regex-sdk";
import { useZkEmailSDK } from "@zk-email/zk-email-sdk";

const CIRCUIT_NAME = "twitter";

Expand All @@ -53,7 +53,7 @@ export const MainPage: React.FC<{}> = (props) => {
generateProofRemotely,
proofStatus,
inputWorkers,
} = useZkRegex();
} = useZkEmailSDK();

const [ethereumAddress, setEthereumAddress] = useState<string>(address ?? "");
const [emailFull, setEmailFull] = useState<string>(
Expand Down Expand Up @@ -95,6 +95,9 @@ export const MainPage: React.FC<{}> = (props) => {
useState<boolean>(false);
const [areInputWorkersCreating, setAreInputWorkerCreating] =
useState<boolean>(false);
const [externalInputs, setExternalInputs] = useState<Record<string, string>>(
{}
);

const [stopwatch, setStopwatch] = useState<Record<string, number>>({
startedDownloading: 0,
Expand Down Expand Up @@ -204,6 +207,19 @@ export const MainPage: React.FC<{}> = (props) => {
if (!inputWorkers["zk-email/proof-of-twitter-v2"]) {
setAreInputWorkerCreating(true);
createInputWorker("zk-email/proof-of-twitter-v2");
const entryExternalInputs = [
{
name: "address",
maxLength: 64,
},
];

for (const input of entryExternalInputs) {
setExternalInputs({
...externalInputs,
[input.name]: "",
});
}
}
}, []);

Expand Down Expand Up @@ -273,7 +289,8 @@ export const MainPage: React.FC<{}> = (props) => {
setIsRemoteProofGenerationLoading(true);
const input = await generateInputFromEmail(
"zk-email/proof-of-twitter-v2",
emailFull
emailFull,
externalInputs
);
const body = Buffer.from(input.emailBody).toString("utf-8");
console.log("input", input);
Expand Down
Loading

0 comments on commit 8cde0e1

Please sign in to comment.