Skip to content

Commit

Permalink
add support for message query param
Browse files Browse the repository at this point in the history
  • Loading branch information
marcusmolchany committed Oct 15, 2022
1 parent 02975ff commit c88e887
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
12 changes: 9 additions & 3 deletions src/components/SignatureForm.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { utils as ethersUtils } from "ethers";
import { ChangeEvent, useMemo, useState } from "react";
import { ChangeEvent, ReactElement, useMemo, useState } from "react";
import { useAccount, useSignMessage } from "wagmi";
import { CopyButton } from "./CopyButton";
import { EmailButton } from "./EmailButton";
Expand Down Expand Up @@ -40,11 +40,17 @@ const getPremessage = ({
const INITIAL_MESSAGE =
"hereby decree that this message has been signed by me.\n\nSigned using Wallet Sign";

export function SignatureForm() {
type Props = {
initialMessage?: string;
};

export function SignatureForm({
initialMessage = INITIAL_MESSAGE,
}: Props): ReactElement {
const { address } = useAccount();
const { signMessageAsync } = useSignMessage();
const [name, setName] = useState<string>("");
const [message, setMessage] = useState<string>(INITIAL_MESSAGE);
const [message, setMessage] = useState<string>(initialMessage);
const [messageThatWasSigned, setMessageThatWasSigned] = useState<string>("");
const [signedMessage, setSignedMessage] = useState<string>("");
const [hashedMessage, setHashedMessage] = useState<string>("");
Expand Down
6 changes: 5 additions & 1 deletion src/routes/Sign.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
import { useSearchParams } from "react-router-dom";
import { SignatureForm } from "../components/SignatureForm";

export function Sign() {
return <SignatureForm />;
const [searchParams] = useSearchParams();
const message = searchParams.get("message") || undefined;

return <SignatureForm initialMessage={message} />;
}

0 comments on commit c88e887

Please sign in to comment.